/// <summary> /// Instantiates the object. /// </summary> /// <param name="abstractTypeCreationContext">The abstract type creation context.</param> /// <returns></returns> /// <exception cref="System.NullReferenceException">Configuration Resolver pipeline did not return a type. Has the type been loaded by Glass.Mapper. Type: {0}.Formatted(abstractTypeCreationContext.RequestedType.FullName)</exception> public object InstantiateObject(AbstractTypeCreationContext abstractTypeCreationContext) { using (new Monitor()) { string profilerKey = "Creating {0}".Formatted(abstractTypeCreationContext.Options.Type.FullName); try { Profiler.IndentIncrease(); Profiler.Start(profilerKey); if (this._disposed) { throw new MapperException("Service has been disposed, cannot create object"); } //run the pipeline to get the configuration to load var configurationArgs = RunConfigurationPipeline(abstractTypeCreationContext); if (configurationArgs.Result == null) { throw new NullReferenceException( "Configuration Resolver pipeline did not return a type. Has the type been loaded by Glass.Mapper. Type: {0}" .Formatted(abstractTypeCreationContext.Options.Type)); } //Run the object construction var objectArgs = new ObjectConstructionArgs( GlassContext, abstractTypeCreationContext, configurationArgs.Result, this ); objectArgs.Parameters = configurationArgs.Parameters; _objectConstruction.Run(objectArgs); ModelCounter.Instance.ModelsRequested++; return(objectArgs.Result); } finally { //we clear the lazy loader disable to avoid problems with //stack overflows on the next request Profiler.End(profilerKey); Profiler.IndentDecrease(); } } }
/// <summary> /// Instantiates the object. /// </summary> /// <param name="abstractTypeCreationContext">The abstract type creation context.</param> /// <returns></returns> /// <exception cref="System.NullReferenceException">Configuration Resolver pipeline did not return a type. Has the type been loaded by Glass.Mapper. Type: {0}.Formatted(abstractTypeCreationContext.RequestedType.FullName)</exception> public object InstantiateObject(AbstractTypeCreationContext abstractTypeCreationContext) { //run the pipeline to get the configuration to load var configurationArgs = RunConfigurationPipeline(abstractTypeCreationContext); if (configurationArgs.Result == null) { throw new NullReferenceException("Configuration Resolver pipeline did not return a type. Has the type been loaded by Glass.Mapper. Type: {0}".Formatted(abstractTypeCreationContext.RequestedType)); } //Run the object construction var objectArgs = new ObjectConstructionArgs(GlassContext, abstractTypeCreationContext, configurationArgs.Result, this); objectArgs.Parameters = configurationArgs.Parameters; _objectConstruction.Run(objectArgs); return(objectArgs.Result); }