This is my attempt at a very flexible generic repository for an n-layer MVC project.
I've got this placed in my business/service layer which any DAL (Data Access Layer) project can reference and implement.
| Note: IFileService is not completely necessary unless you’re doing Xamarin Forms and need. | |
| public static HtmlString SerializeViewModel(this HtmlHelper helper, object viewModel, JsonSerializerSettings serializer = null) | |
| { | |
| if (serializer == null) | |
| { | |
| serializer = | |
| new JsonSerializerSettings {ContractResolver = new CamelCasePropertyNamesContractResolver()}; | |
| } | |
| return new HtmlString(JsonConvert.SerializeObject(viewModel, serializer)); | |
| } |
| /// <summary> | |
| /// Adds <paramref name="newClass"/> to <paramref name="output"/> or appends it. | |
| /// </summary> | |
| /// <param name="output"></param> | |
| /// <param name="newClass"></param> | |
| public static void AddClass(this TagHelperOutput output, string newClass) | |
| { | |
| var classAttribute = output.Attributes.FirstOrDefault(a => a.Name == "class"); | |
| if (classAttribute == null) | |
| { |
| using System; | |
| using System.Diagnostics; | |
| using System.Threading.Tasks; | |
| using JetBrains.Annotations; | |
| using Microsoft.AspNetCore.Builder; | |
| using Microsoft.AspNetCore.Diagnostics; | |
| using Microsoft.AspNetCore.Http; | |
| using Microsoft.Extensions.Logging; | |
| using Microsoft.Extensions.Options; | |
| using Microsoft.Net.Http.Headers; |
| /// <remarks/> | |
| [System.SerializableAttribute()] | |
| [System.ComponentModel.DesignerCategoryAttribute("code")] | |
| [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)] | |
| [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)] | |
| public partial class packages | |
| { | |
| private packagesPackage[] packageField; |
| <script> | |
| (function () { | |
| var CSSSteal = function () { | |
| var api = {}, html = null, styles = [], indent = ' ', elements = false, args = arguments; | |
| var requirements = function () { | |
| if (args.length === 0) { | |
| throw new Error('CSSSteal expects at least one argument (DOM element)'); | |
| } |
Each of the sections below allow you to click on a bookmark/favorite to quickly search your local public library for a book you are looking at on Amazon. The goal is to save money (and bookshelf clutter :)) so you can check out a book (see what I did there?) instead of buying it first.
##Quick Guide
Here's how you use these. It's probably going to be easiest to copy the bookmarklet code by clicking "Raw":
| <#@ template debug="true" hostSpecific="true" #> | |
| <#@ assembly name="System.Core" #> | |
| <#@ Assembly Name="EnvDTE" #> | |
| <#@ import namespace="EnvDTE" #> | |
| <#@ import namespace="System.Linq" #> | |
| <#@ import namespace="System.Text" #> | |
| <#@ import namespace="System.Collections.Generic" #> | |
| <#@ output extension=".ts" #> | |
| module Routing { | |
| <# |
| // C# templates | |
| // Sample file | |
| space ::= " " | |
| cursor ::= "$END$" | |
| cursorb ::= "(" cursor ")" | |
| // Resharper macros: | |
| identifier ::= <name default="$name$" macros = "complete()"> | |
| identifier2 ::= <name2 default="$name2$" macros = "complete()"> | |
| // |