Skip to content

Instantly share code, notes, and snippets.

Derek Comartin dcomartin

Block or report user

Report or block dcomartin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dcomartin
dcomartin / gist:82a81fa4f5a217c50702
Last active Aug 29, 2015
Unity Container with MediatR
View gist:82a81fa4f5a217c50702
public static void RegisterTypes(IUnityContainer container)
{
container.RegisterType<IRepository>(new InjectionFactory(context => new EventStoreRepository(context.Resolve<IStoreEvents>(), new AggregateFactory(), new ConflictDetector())));
container.RegisterType<IMediator>(new InjectionFactory(x => new Mediator(() => new UnityServiceLocator(x))));
container.RegisterTypes(AllClasses.FromAssemblies(typeof(Commands.InventoryCommandHandler).Assembly), WithMappings.FromAllInterfaces, GetName, GetLifetimeManager);
container.RegisterTypes(AllClasses.FromAssemblies(typeof(Queries.InventoryQueryHandler).Assembly), WithMappings.FromAllInterfaces, GetName, GetLifetimeManager);
container.RegisterType<IStoreEvents>(new InjectionFactory(context => Wireup.Init()
.UsingSqlPersistence("EventStore")
.WithDialect(new MySqlDialect())
.EnlistInAmbientTransaction()
@dcomartin
dcomartin / gist:5e2aae81a5154507fc98
Last active Aug 29, 2015
Unity RegisterType IMediator
View gist:5e2aae81a5154507fc98
container.RegisterType<IMediator>(new InjectionFactory(x => new Mediator(() => new UnityServiceLocator(x))));
View gist:715f97d5765fac8e426a
public Mediator(ServiceLocatorProvider serviceLocatorProvider);
View gist:12fe98b3cd40d332c5ff
using System;
using System.Threading.Tasks;
namespace dcomartin.Demo.AsyncAwaitExceptions
{
class Program
{
static void Main(string[] args)
{
// Since main entry does not support async, lets create a async task.
View gist:23b218f13cc08b9e37b5
Add("sendErrorEmails", true);
Add("errorEmail", "derek@codeopinion.com");
View gist:797398291f51ed0c27ad
// Load from file system
Config.Global.LoadScriptFile("path/to/MyConfig.csx");
// Load from web
Config.Global.LoadWebScript(new Uri("https://www.domain.com/MyConfig.csx"));
View gist:61cde468dff3efdb0995
var sendErrorEmails = Config.Global.Get<bool>("sendErrorEmails");
var errorEmail = Config.Global.Get<string>("errorEmail");
View gist:0d2d3e72eabe863987af
namespace AnotherProject
{
public class ErrorConfig
{
public bool SendEmails { get; set; }
public string Email { get; set; }
}
}
View gist:74d2a6e8f9b2c379924d
#r bin/AnotherProject.dll
using AnotherProject;
Add("error", new ErrorConfig { SendEmails = true, Email = "derek@codeopinion.com" });
Add("sendErrorEmails", true);
Add("errorEmail", "derek@codeopinion.com");
View gist:9ead866d4460e024cb18
var errorConfig = Config.Global.Get<ErrorConfig>("error");
You can’t perform that action at this time.