예제 #1
0
        public object CreateObjectAsSingle(Type type, params object[] args)
        {
            var key = type.Name;

            if (container.ContainsKey(key))
            {
                return(container[key]);
            }

            IObjectActivator activator = null;

            if (!objectActivators.ContainsKey(key))
            {
                var argsType = Array.ConvertAll(args, x => x.GetType());
                activator = CreateActivator(type, argsType);
                objectActivators.Add(key, activator);
            }
            else
            {
                activator = objectActivators[key];
            }

            var obj = activator.Create(args);

            container.Add(key, obj);

            return(obj);
        }
예제 #2
0
        protected object Create(params object[] args)
        {
            var obj = objectActivator.Create(args);

            DIComponentsInitializer.Inject(obj);
            return(obj);
        }