private static Container CreateRootContainer([NotNull][ItemNotNull] IEnumerable <IConfiguration> configurations) { var container = new Container(string.Empty, NullContainer.Shared); container.ApplyConfigurations(configurations); return(container); }
public static Container Create([NotNull] string name = "", [NotNull][ItemNotNull] params IConfiguration[] configurations) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (configurations == null) { throw new ArgumentNullException(nameof(configurations)); } // Create a root container var lockObject = new LockObject(); var rootContainer = new Container(string.Empty, RootContainer.Shared, lockObject); rootContainer.Register <ILockObject>(ctx => lockObject); if (configurations.Length > 0) { if (!configurations.Any(i => i is CoreFeature)) { rootContainer.ApplyConfigurations(CoreFeature.Set); } rootContainer.ApplyConfigurations(configurations); } else { rootContainer.ApplyConfigurations(DefaultFeature.Set); } // Create a target container var container = new Container(CreateContainerName(name), rootContainer, lockObject); container.RegisterResource(rootContainer); return(container); }