This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using Ninject; | |
namespace ScratchPad | |
{ | |
public class Foo : IBoo, IBaz | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a declaration | |
public static class Declarations | |
{ | |
public static readonly ExodataDeclaration<bool> IsValidator = new ExodataDeclaration<bool>(default: false); | |
} | |
// code to define | |
Bind(Declarations.IsValidator) | |
.Given<string>() | |
.For<Type>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (var windowsTimeZone in TimeZoneInfo.GetSystemTimeZones()) | |
{ | |
var olsonTimeZoneProvider = new TzdbTimeZoneProvider("NodaTime.TimeZones.Tzdb"); | |
var olsonTimeZone = olsonTimeZoneProvider.MapTimeZoneId(windowsTimeZone); | |
Console.WriteLine(olsonTimeZone ?? string.Format("{{{0}}}", windowsTimeZone.Id)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Validator | |
{ | |
public static Outcome<string> ValidatePassword(IDssPrincipal principal, string password) | |
{ | |
Outcome<string> result = Outcome.Success(); | |
Maybe<string> email = principal.ToMaybe() | |
.Select(x => x.Identity) | |
.Select(x => x.EmailAddress); | |
// Password cannot be empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Validator | |
{ | |
public static Outcome<string> ValidatePassword(IDssPrincipal principal, string password) | |
{ | |
const int minimumLength = 8; | |
const int maximumLength = 20; | |
return Outcome.Success() | |
// Password cannot be empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Outcome.Success() | |
.FailIf(true, "failed") | |
.Let(x => | |
{ | |
if(x.WasSuccessful) | |
{ | |
return x & Outcome.FailIf(true, "this is the expensive check"); | |
} | |
return x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Example | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var theA = new A(a => new B(a)); | |
var theB = theA.TheB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace SpracheTestbed | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var parser = from greeting in Parse.String("Hello") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static JToken ConvertFromXml(XElement element) | |
{ | |
if (!element.HasAttributes && !element.HasElements) | |
return new JValue(element.Value); | |
var attributes = element.Attributes() | |
.Select(x => new JProperty(NormalizeName(x.Name.LocalName), x.Value)); | |
var elements = element.Elements() | |
.GroupBy(x => x.Name.LocalName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Context() | |
{ | |
IntPtr libPtr = Native.LoadLibrary("libzmq"); | |
if (libPtr == IntPtr.Zero) | |
{ | |
LoadEmbeddedLibary(); | |
} | |
} | |
private static void LoadEmbeddedLibary() |
OlderNewer