Skip to content

Instantly share code, notes, and snippets.

public UserManager()
: base(new UserStore<ApplicationUser>(new ApplicationDbContext()))
{
UserValidator = new UserValidator<ApplicationUser>(this) { AllowOnlyAlphanumericUserNames = false };
}
@OdeToCode
OdeToCode / gist:e43279d671b7930018a4
Created May 13, 2014 12:26
Subscribe and unsubscribe from events
public class Worker
{
public void StartWork()
{
for (var i = 0; i < 10; i++)
{
OnInterestingEvent();
Thread.Sleep(1000);
}
OnComplete();
<Window x:Class="WpfApplication8.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
<!-- event wire up here: -->
Loaded="MainWindow_Loaded">
<Canvas x:Name="DrawingCanvas">
</Canvas>
public class Logger(Stream stream) : IDisposable
{
public void Dispose()
{
Stream.Dispose();
}
public Stream Stream { get; set; } = stream;
}
let range = function*(start, end){
let current = start;
while(current < end){
let newValue = yield current;
current = newValue ? newValue : current + 1;
}
};
let stuff = range(0,3)
let range = function*(start, end){
for(var i = start; i <= end; i++){
yield i;
}
};
let n = [for (x of range(0,3)) x];
expect(n).toEqual([0,1,2,3]);
// this:
var foo = "hi!";
var length = foo?.Length;
// will create this:
string str = "hi!";
int? nullable = str != null ? new int?(str.Length) : new int?();
// while this:
var foo = "hi!";
var generatedCode = generator.TransformText();
var comparer = DesktopAssemblyIdentityComparer.Default;
var options = new CSharpCompilationOptions(
OutputKind.DynamicallyLinkedLibrary,
assemblyIdentityComparer:comparer);
var tree = SyntaxFactory.ParseSyntaxTree(generatedCode);
var compilation = CSharpCompilation
.Create("measures.dll")
<configuration>
<appSettings>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
</configuration>
public class Employee
{
public Employee()
{
HomeAddress = new Address();
}
public int Id { get; set; }
public string Name { get; set; }
public Address HomeAddress { get; set; }