Created
July 29, 2014 23:21
-
-
Save wshaddix/9351e616f4874cc35649 to your computer and use it in GitHub Desktop.
IoC Class for minimal configuration of Rollbar logging and StatHat stats
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.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