Пример #1
0
        private static Func <object> GetCreator(SimpleComponentElement component)
        {
            if (component.Scope == InstanceScope.Transient)
            {
                return(component.CreateInstance);
            }

            object instance = component.CreateInstance();

            return(() => instance);
        }
Пример #2
0
        ///<summary>
        /// Register all of the components found in the <see cref="SimpleContainerSection"/>
        ///</summary>
        ///<returns>An instance of self so the Register calls can be chained.</returns>
        public IDependencyContainer RegisterFromConfig()
        {
            SimpleContainerSection section = SimpleContainerSection.Load("container");

            for (int i = 0; i < section.Components.Count; i++)
            {
                SimpleComponentElement component = section.Components[i];
                Register(component.ServiceType, GetCreator(component));
            }

            return(this);
        }