Skip to content

Instantly share code, notes, and snippets.

View filipw's full-sized avatar
🦄
¯\_(ツ)_/¯

Filip W filipw

🦄
¯\_(ツ)_/¯
View GitHub Profile
@filipw
filipw / gist:3160050
Created July 22, 2012 15:47
BSON media type formatter for ASP.NET Web API RC
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Xml;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Net.Http.Formatting;
using System.Net.Http;
using System;
@filipw
filipw / MessagePackMediaTypeFormatter
Created September 10, 2012 19:43
MessagePack for Web API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Http.Formatting;
using MsgPack.Serialization;
using System.Threading.Tasks;
using System.IO;
using System.Net.Http.Headers;
using System.Net;
@filipw
filipw / webapiScript.csx
Created September 27, 2012 10:42
Scripting self hosted Web API with Roslyn CTP
#r "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Http.SelfHost.dll"
#r "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Newtonsoft.Json.4.5.6\lib\net40\Newtonsoft.Json.dll"
#r "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Http.dll"
#r "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Net.Http.Formatting.dll"
#r "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Net.Http.WebRequest.dll"
#r "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Net.Http.dll"
#r "c:\Users\Filip\documents\visual studio 2012\Projects\Roslyn.WebApi\packages\Roslyn.Compilers.Common.1.2.20906.2\lib\net45\Roslyn.Compilers.dll"
#r "c:\users\filip\documents\visual studio 2012\Projects\Roslyn.WebApi\packages\Roslyn.Compilers.CSharp.1.2.20906.2\lib\net45\Roslyn.Compilers.CSharp.dll"
using System;
@filipw
filipw / gist:4502859
Last active October 30, 2023 21:14
Generic EF repository
public class GenericRepository<TEntity> : IGenericRepository<TEntity> where TEntity : class, IId
{
internal DbContext Context;
internal DbSet<TEntity> DbSet;
public ICache Cache { get; set; }
public GenericRepository(DbContext context)
{
Context = context;
@filipw
filipw / CompiledPropertyAccessor.cs
Last active March 4, 2024 04:17
removed unnecessary classes
using System;
using System.Linq.Expressions;
using System.Reflection;
using WebApi.Delta;
namespace Hst.Deals.API.Infrastructure
{
internal class CompiledPropertyAccessor<TEntityType> : PropertyAccessor<TEntityType> where TEntityType : class
{
private Action<TEntityType, object> _setter;
public static MethodInfo GetMethodInfo<T, U>(Expression<Func<T, U>> expression)
{
var method = expression.Body as MethodCallExpression;
if (method != null)
return method.Method;
throw new ArgumentException("Expression is wrong");
}
public static MethodInfo GetMethodInfo<T, U>(Expression<Action<T>> expression)
@filipw
filipw / gist:5087814
Created March 5, 2013 03:40
Get relevant assemblies with Nuget.Core
public IEnumerable<string> GetAssemblyNames(List<string> packageids, string version)
{
var packageDir = _fileSystem.CurrentDirectory + @"\" + "packages";
if (!Directory.Exists(packageDir))
return Enumerable.Empty<string>();
var items = new List<string>();
var repository = new LocalPackageRepository(packageDir);
@filipw
filipw / gist:5562717
Created May 12, 2013 07:12
scriptcs quick start
//scriptcs -install scriptcs.webapi
var webApi = Require<WebApi>();
var server = webApi.CreateServer("http://localhost:8080");
server.OpenAsync().Wait();
Console.ReadKey();
@filipw
filipw / app.csx
Last active August 29, 2015 13:56
nancy on helios with OWIN and scriptcs
#load "bootstrapper.csx" //setup rootpathprovider and other stuff
public class IndexModule : NancyModule
{
public IndexModule()
{
Get["/"] = x => {
return View["index"];
};
}
@filipw
filipw / app.csx
Last active November 4, 2015 19:34
#load "bootstrapper.csx"
public class IndexModule : NancyModule
{
public IndexModule()
{
Get["/"] = x => {
return View["index"];
};
}