Skip to content

Instantly share code, notes, and snippets.

@wshaddix
Created July 29, 2014 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wshaddix/9351e616f4874cc35649 to your computer and use it in GitHub Desktop.
Save wshaddix/9351e616f4874cc35649 to your computer and use it in GitHub Desktop.
IoC Class for minimal configuration of Rollbar logging and StatHat stats
using System.Configuration;
using Insiders.Web.Infrastructure.Logging.Implementation;
using Insiders.Web.Infrastructure.Logging.Interfaces;
using Insiders.Web.Infrastructure.Stats.Implementation;
using Insiders.Web.Infrastructure.Stats.Interfaces;
using StructureMap;
using StructureMap.Graph;
namespace Insiders.Web.Infrastructure.IoC
{
public static class IoC
{
public static IContainer Initialize()
{
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
x.For<ILog>().Use<RollbarLogger>();
x.For<IStats>().Singleton().Use<StatHatStatistics>()
.Ctor<string>("statHatKey").Is(ConfigurationManager.AppSettings["StatHatKey"])
.Ctor<bool>("logStats").Is(bool.Parse(ConfigurationManager.AppSettings["LogStats"]))
.Ctor<string>("applicationName").Is(ConfigurationManager.AppSettings["ApplicationName"])
.Ctor<string>("environment").Is(ConfigurationManager.AppSettings["Environment"]);
});
return ObjectFactory.Container;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment