public void Configure(Action <ConfigurationExpression> configure) { var registry = new ConfigurationExpression(); configure(registry); if (registry.HasPolicyChanges() && Role == ContainerRole.Nested) { throw new StructureMapConfigurationException("Policy changes to a nested container are not allowed. Policies can only be applied to the root container"); } var builder = new PluginGraphBuilder(_pluginGraph); builder.Add(registry); registry.Registries.Each(x => x.As <IPluginGraphConfiguration>().Register(builder)); registry.Registries.Each(x => builder.Add(x)); builder.RunConfigurations(); if (registry.HasPolicyChanges()) { Instances.GetAllInstances().ToArray().Each(x => x.ClearBuildPlan()); Profiles.AllProfiles().ToArray() .Each(x => x.Instances.GetAllInstances().ToArray().Each(i => i.ClearBuildPlan())); } }
public void Dispose() { if (_wasDisposed) { return; } _wasDisposed = true; if (Role == ContainerRole.Root) { _singletons.DisposeAndClear(); } ContainerCache.DisposeAndClear(); _transients.DisposeAndClear(); _pluginGraph.SafeDispose(); if (Role == ContainerRole.Root) { _profiles.AllProfiles().Each(x => x.Dispose()); } _trackedDisposables.Each(x => x.Dispose()); }
public void Configure(Action <ConfigurationExpression> configure) { if (_pluginGraph.IsRunningConfigure) { throw new StructureMapConfigurationException("The container is already being configured. Recursive IContainer.Configure() calls are not allowed"); } _pluginGraph.IsRunningConfigure = true; try { var registry = new ConfigurationExpression(); configure(registry); var transientTracking = registry.GetTransientTracking(); if (transientTracking != null && transientTracking != _pluginGraph.TransientTracking) { changeTransientTracking(transientTracking.Value); } if (registry.HasPolicyChanges() && Role == ContainerRole.Nested) { throw new StructureMapConfigurationException("Policy changes to a nested container are not allowed. Policies can only be applied to the root container"); } if (registry.HasPolicyChanges()) { _pluginGraph.ClearTypeMisses(); } var builder = new PluginGraphBuilder(_pluginGraph); builder.Add(registry); registry.Registries.Each(x => builder.Add(x)); builder.RunConfigurations(); if (registry.HasPolicyChanges()) { Instances.GetAllInstances().ToArray().Each(x => x.ClearBuildPlan()); Profiles.AllProfiles().ToArray() .Each(x => x.Instances.GetAllInstances().ToArray().Each(i => i.ClearBuildPlan())); } } finally { _pluginGraph.IsRunningConfigure = false; } }
public void Configure(Action <ConfigurationExpression> configure) { var registry = new ConfigurationExpression(); configure(registry); var builder = new PluginGraphBuilder(_pluginGraph); builder.Add(registry); registry.Registries.Each(x => x.As <IPluginGraphConfiguration>().Register(builder)); registry.Registries.Each(x => builder.Add(x)); builder.RunConfigurations(); if (registry.HasPolicyChanges()) { Instances.GetAllInstances().ToArray().Each(x => x.ClearBuildPlan()); Profiles.AllProfiles().ToArray() .Each(x => x.Instances.GetAllInstances().ToArray().Each(i => i.ClearBuildPlan())); } }