Premise
A base library for .net applications that supports all of the basic things developers want to do :).
This library is intended to help .net developers quickly scaffold and build great applications! From providing support for generic repositories and advanced data structures to helpful UI helpers for popular frameworks, Premise will help save development time and redundant plumbing code in every application!
Premise.Data
The Premise.Data namespace provides all of the neccessary classes to implement a generic repository pattern. Initializing a Repository will quickly provide basic CRUD functionality. Dependency injection is supported through the use of the generic IRepository interface, allowing underlying data providers to be swapped at runtime.
//Declare new book repository
public class BookRepository : Repository<Book>()
{
public BookRepository(IDataContext context)
{
//...
}
}
//CRUD actions available for use
var repository = new BookRepository(DbContext);
var books = repository.GetAll();
Support for advanced paging is automatically brought in using the generic Pageable interface.
public IActionResult Index(int page, int pageSize = 10)
{
var repository = new Repository<Book>();
var books = new Pageable<Book>(Request, repository.GetAll());
return books;
}
@model Pageable<Book>
<ul>
@foreach (var book in Model) {
<li>
@book.Name
</li>
}
</ul>
@Html.ZurbPager(Model)
Premise.Collections
The Premise.Collections namespace provides some useful collections for basic tasks.
The generic BlockingQueue provides a thread safe data structure for notifying a watcher when data is placed into the queue. The Dequeue() method suspends the current thread until data is placed in the queue. This eliminates the need for traditional polling loops.
//Create queue
var queue = new BlockingQueue<int>();
//Background watcher
new Thread(() =>
{
while (true)
{
Console.WriteLine(queue.Dequeue());
}
}).Start();
//Enqueue item
for (var i = 0; i < Int32.MaxValue; i++) {
queue.Enqueue(i);
}
Premise.Web.UI.Foundation
The Premise.Web.UI.Foundation namespace provides HtmlHelper extensions for Zurb Foundation.
Quickly generate buttons, use font-awesome icons, etc. Some examples below.
//Icon helper
@Html.Icon("edit")
<!-- Generated html -->
<i class="fa fa-edit"></i>
//Button helper
@Html.ZurbButton("Edit Book", "Edit", new { id = 25 }, new { @class = "myclass" }, ZurbSize.Small, ZurbColor.Success)
<!-- Generated html -->
<a class="myclass button small success" href="/Book/Edit?id=25" title="Edit Book">Edit Book</a>