Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Metadata;
using System.Threading.Tasks;
using Marten;
using Marten.Events.Projections;
using Xunit;
using Xunit.Abstractions;
@slovely
slovely / Program.cs
Last active June 21, 2020 10:43
EF Core StackOverflowException
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace StackOverflowTest
{
public class Program
{
public static string ConnectionString =
@slovely
slovely / TypeScript-Generation.ts
Created March 7, 2017 15:08
Generated WebAPI actions
// Assume a WebAPI action on the server
// [HttpPost]
// public SomeType TheAction(string s, AnotherType obj) {
// return new SomeType(s.Length, obj.name);
// }
// Where SomeType is
// public class SomeType{ public int Property1{get;set;} public string Property2{get;set;}}
// and AnotherType is
// public class AnotherType {public string Name{get;set;}}
@slovely
slovely / maps.js
Created January 27, 2016 22:13
OverlappingFeatureSpiderfier.js example
<html>
<head>
<style type="text/css">
html, body { height: 100%; margin: 0; padding: 0; }
#map { height: 100%; }
</style>
</head>
<body>
@slovely
slovely / program.cs
Created October 30, 2014 22:15
Sample console app for generating TypeScript models
using System;
using System.IO;
using System.Reflection;
using TypeLite;
namespace TypeScriptSample.Generator
{
class Program
{
static void Main(string[] args)
@slovely
slovely / generated.ts
Created October 28, 2014 22:17
Complete output from TypeLite fork
declare module TypeLite.Tests.GenericsTests {
interface ClassWithComplexNestedGenericProperty {
GenericsHell: System.Tuple<System.Collections.Generic.KeyValuePair<number, string>, TypeLite.Tests.GenericsTests.BaseGeneric<string>, number, System.Collections.Generic.KeyValuePair<number, DummyNamespace.Test>>;
}
interface BaseGeneric<TType> {
SomeGenericProperty: TType;
SomeGenericArrayProperty: TType[];
}
}
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace ConsoleApplication1
{
[TestClass]
public class CustomMoq
{
public class Message
{
@slovely
slovely / Enumeration.cs
Created July 11, 2011 17:47
Type-safe Enumerations in c#
public class MyType : Enumeration
{
//don't allow type to be constructed
private MyType(int value, string displayName) : base(value, displayName) { }
public static readonly MyType Type1 = new MyType(1, "Type One");
public static readonly MyType Type2 = new MyType(2, "Type Two");
public static readonly MyType DerivedType3 = new DerivedMyType(3, "Type Three");
public virtual int GetSomethingAboutThisType()