Skip to content

Instantly share code, notes, and snippets.

View benjanderson's full-sized avatar
😀

Ben Anderson benjanderson

😀
View GitHub Profile
@benjanderson
benjanderson / ChangeBaseHrefMiddleware.cs
Created February 2, 2018 21:27
Asp.net core 2.1 middleware that changes base href to support IIS virtual directory for SPA applications. Handy for Angular, React, Vue...
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using System.IO;
using System.Text;
using System.Threading.Tasks;
public class ChangeBaseHrefMiddleware
{
RequestDelegate next;
private readonly IConfiguration configuration;
import {trigger, animate, style, group, animateChild, query, stagger, transition} from '@angular/animations';
export const routerTransition = trigger('routerTransition', [
transition('* <=> *', [
/* order */
/* 1 */ query(':enter, :leave', style({ position: 'fixed', width:'100%' })
, { optional: true }),
/* 2 */ group([ // block executes in parallel
query(':enter', [
<div class="row">
<div class="col-md-8">
<ul id="colorWheel1" class="sortable"></ul>
<ul id="colorWheel2" class="sortable"></ul>
<ul id="colorWheel3" class="sortable"></ul>
<ul id="colorWheel4" class="sortable"></ul>
</div>
</div>
[TestMethod]
public void MyTestMethod()
{
this.Container.RegisterType<FactoryBase<Binding>, CustomBinding1>();
var fixture1 = this.Container.Resolve<IFixture>();
fixture1.Create<Binding>();
this.Container.RegisterType<FactoryBase<Binding>, CustomBinding2>();
var fixture2 = this.Container.Resolve<IFixture>();
[TestMethod]
public void MyTestMethod()
{
this.Container.RegisterType<FactoryBase<Entity>, CustomEntityFactory>();
this.Container.RegisterType<FactoryBase<Binding>, CustomBinding1>("binding1");
this.Container.RegisterType<FactoryBase<Binding>, CustomBinding2>("binding2");
var fixture = this.Container.Resolve<IFixture>();
fixture.Create<Binding>();
fixture.Create<DataMart>();
}
public interface IFileUploader
{
Task<FileInfo> GetUploadedFile(HttpContent content, string expectedExtension);
}
public class FileUploader : IFileUploader
{
public async Task<FileInfo> GetUploadedFile(HttpContent content, string expectedExtension)
{
if (!content.IsMimeMultipartContent())
@benjanderson
benjanderson / SqlExceptionCreator
Created March 23, 2015 16:15
Creates SqlException through reflection and sets ErrorMessage and ErrorCode. Be aware this reflects private functionality which is likely to change, do not use this in production code
public static class SqlExceptionCreator
{
public static SqlException Create(string message, int errorCode)
{
SqlException exception = Instantiate<SqlException>();
SetProperty(exception, "_message", message);
var errors = new ArrayList();
var errorCollection = Instantiate<SqlErrorCollection>();