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.Reflection; | |
using System.Threading.Tasks; | |
using MediatR; | |
using StructureMap; | |
using StructureMap.Graph; | |
using StructureMap.Graph.Scanning; | |
using Xunit; | |
namespace MediatrSmTest |
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 Match | |
{ | |
public static PatternMatch<T, R> With<T, R>(T value) | |
{ | |
return new PatternMatch<T, R>(value); | |
} | |
public struct PatternMatch<T, R> | |
{ | |
private readonly T _value; |
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 class OrderController : Controller | |
{ | |
// constructor and other dependent objects | |
[HttpPost, ValidateAntiForgeryToken] | |
public ActionResult Pay(PayRequest request) | |
{ | |
var order = _repository.Get(request.OrderId); | |
_logger.InfoOperations("Trying to pay the order ", payRequest) | |
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 class LoggerExtension | |
{ | |
public static void InfoDiagnostics(this ILogger logger, string message, params object[] data) | |
{ | |
logger.Log(LogLevel.Info, LogType.Diagnostics, message, data); | |
} | |
public static void InfoOperations(this ILogger logger, string message, params object[] data) | |
{ | |
logger.Log(LogLevel.Info, LogType.Operations, message, data); | |
} |
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
interface ILogger | |
{ | |
void Log(LogLevel level, LogType type, string message) | |
} |
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
let matches (pattern : string) (x : string) : bool = | |
let rec matchesL pattern x = | |
match pattern, x with | |
| [], [] -> true | |
| '?'::pTail, xHead::xTail -> matchesL pTail xTail || matchesL pTail x | |
| '*'::pTail, xHead::xTail -> matchesL pTail xTail || matchesL pTail x || matchesL pattern xTail | |
| pHead::pTail, xHead::xTail when pHead = xHead -> matchesL pTail xTail | |
| _ -> false |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var server = WebApp.Start("http://+:56789", builder => | |
{ | |
var configuration = new HttpConfiguration(); | |
configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; | |
configuration.Routes.MapHttpRoute("default", "api/{controller}"); | |
configuration.Formatters.JsonFormatter.SerializerSettings.TypeNameHandling = TypeNameHandling.Auto; |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Database.SetInitializer(new DropCreateDatabaseAlways<PeopleContext>()); | |
var context = new PeopleContext(); | |
context.Database.Log = Console.WriteLine; // so we can inspect SQL statements | |
AddOnePerson(context); |
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
// https://github.com/hudo/Sample-UrlShortener | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Threading.Tasks; | |
using Owin; | |
using Raven.Client; | |
using Raven.Client.Embedded; |
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 DataContextExtensions | |
{ | |
/// <summary> | |
/// Map private collection property | |
/// </summary> | |
/// <typeparam name="T">Entity type</typeparam> | |
/// <typeparam name="R">Collection entity</typeparam> | |
/// <param name="propertyName">property name</param> | |
public static ManyNavigationPropertyConfiguration<T, R> HasMany<T, R>(this EntityTypeConfiguration<T> mapper, string propertyName) | |
where T : class |