Skip to content

Instantly share code, notes, and snippets.

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.1.1" />
</ItemGroup>
</Project>
@sphiecoh
sphiecoh / initialdata.cs
Created January 22, 2017 05:30
IdentityServer4.Postgres initial data
using (var session = store.LightweightSession())
{
if(!session.Query<IdentityServer4.Postgresql.Entities.ApiResource>().Any())
{
var resources = new List<IdentityServer4.Postgresql.Entities.ApiResource> {
new IdentityServer4.Postgresql.Entities.ApiResource{ Name = "api1" , Description = "Api" , DisplayName ="api1" },
};
session.StoreObjects(resources);
}
@sphiecoh
sphiecoh / appveyor.yml
Created December 19, 2016 15:58 — forked from mysticmind/appveyor.yml
Marten Appveyor config including installing plv8 extension
version: 1.0.{build}
os: Visual Studio 2015
environment:
marten-testing-database: "Host=localhost;Port=5432;Database=marten_test;Username=postgres;Password=Password12!"
POSTGRES_PATH: C:\Program Files\PostgreSQL\9.5
PG_PLV8_EXTENSION_ZIP_FILENAME: pg95plv8jsbin_w64
PG_DB: marten_test
@sphiecoh
sphiecoh / servicebus.cs
Created October 5, 2016 07:47
Why not subscriptions to events ?
public static async Task<IContainer> CreateEndpoints(IServiceCollection services)
{
var builder = new ContainerBuilder();
builder.Populate(services);
var container = builder.Build();
var settings = container.Resolve<IOptions<ServiceBusHostOptions>>().Value;
var _store = new DocumentStore { Url = settings.Url, DefaultDatabase = settings.DatabaseName };
_store.Initialize();
foreach (var endpoint in settings.Endpoints)
{
@sphiecoh
sphiecoh / bootstrapper.cs
Created September 24, 2016 08:59
Nancy Quartz
IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
IJobDetail job = JobBuilder.Create<QuickJob>().Build();
ITrigger trigger = TriggerBuilder.Create().StartNow().WithSimpleSchedule(x => x
.WithIntervalInSeconds(10)
.RepeatForever()).Build();
protected override void ApplicationStartup(IContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
scheduler.ScheduleJob(job, trigger);
public override void Configure(INancyEnvironment environment)
{
environment.Views(runtimeViewUpdates: true);
base.Configure(environment);
}
@sphiecoh
sphiecoh / atom response
Created May 5, 2016 09:12
Nancy Atom Response
public class AtomResponse : Response
{
public AtomResponse(SyndicationFeed feed)
{
StatusCode = HttpStatusCode.OK;
ContentType = "application/atom+xml";
Contents = stream =>
{
var settings = new XmlWriterSettings
{
public static void GetHandler(this NancyModule module, string path, Func<object> handler)
{
module.Get[path] = _ => RunHandler(module, handler);
}
public static void GetHandler<TIn>(this NancyModule module, string path, Func<TIn, object> handler)
{
module.Get[path] = _ => RunHandler(module, handler);
}