public virtual object Resolve(FastContainer container) { AssertNotDisposed(); if (FastContainer.SupperLogging && Logger.IsDebugEnabled) { Logger.DebugFormat("Resolving Instance"); } if (this.instancePerCall) { if (FastContainer.SupperLogging && Logger.IsDebugEnabled) { Logger.DebugFormat("Building New Instance"); } return this.resolve(container); } if (FastContainer.SupperLogging && Logger.IsDebugEnabled) { Logger.DebugFormat("Attempting To Resolve Instance"); } if (this.instance != null) return this.instance; if (FastContainer.SupperLogging && Logger.IsDebugEnabled) { Logger.DebugFormat("Building And Storing New Instance"); } return this.instance = this.resolve(container); }
/// <summary> /// Initializes the API client. /// </summary> public static void Init() { if (Interlocked.Exchange(ref intializedSignaled, 1) != 0) { return; } handlers = new DispatchHandlers(); handlers.AutoRegisterHandlers(); var connectionString = ConfigurationManager.ConnectionStrings["AdventureWorks"].ConnectionString; dbContextFactory = () => new AdventureWorksDbContext(connectionString); dbConnectionFactory = () => { // use this approach instead of creating a straight SqlConnection to enable profiling var c = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateConnection(); c.ConnectionString = ConfigurationManager.ConnectionStrings["AdventureWorks"].ConnectionString; return(c); }; iocContainer = new FastContainer(); iocContainer.Register <System.Data.Entity.DbContext>(c => c.Resolve <CommandContext>().DbContext); intialized = true; }
public virtual object Resolve(FastContainer container) { AssertNotDisposed(); if (this.instancePerCall) { return this.resolve(container); } if (this.instance != null) { return this.instance; } return this.instance = this.resolve(container); }