Пример #1
0
        /// <summary>
        /// Creates and configures a new ObjectDef for type T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static ObjectDef ForType <T>(Action <ObjectDef> configure)
        {
            var objectDef = new ObjectDef(typeof(T));

            configure(objectDef);

            return(objectDef);
        }
Пример #2
0
        public ObjectDef AddType(Type type)
        {
            var objectDef = new ObjectDef(type);

            Items.Add(objectDef);

            return(objectDef);
        }
Пример #3
0
        public ConfiguredDependency(Type dependencyType, ObjectDef definition)
        {
            if (dependencyType == null)
            {
                throw new ArgumentNullException("dependencyType");
            }

            DependencyType = dependencyType;
            Definition     = definition;
        }
Пример #4
0
        /// <summary>
        /// Adds a concrete type to the list or enumeration
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public ObjectDef AddType(Type type)
        {
            var objectDef = new ObjectDef(type);

            objectDef.ValidatePluggabilityTo(ElementType);

            _items.Add(objectDef);



            return(objectDef);
        }
Пример #5
0
        public ObjectDef Child(Type dependencyType, Type actualType)
        {
            var dependency = new ObjectDef(actualType);

            Dependencies.Add(new ConfiguredDependency
            {
                DependencyType = dependencyType,
                Definition     = dependency
            });

            return(dependency);
        }
Пример #6
0
        /// <summary>
        /// Registers a specific concrete type for the dependencyType
        /// </summary>
        /// <param name="dependencyType"></param>
        /// <param name="actualType"></param>
        /// <returns></returns>
        public ObjectDef DependencyByType(Type dependencyType, Type actualType)
        {
            if (!actualType.IsConcrete())
            {
                throw new ObjectDefException("actualType must be concrete ({0})", actualType.FullName);
            }

            var dependency = new ObjectDef(actualType);

            Dependency(dependencyType, dependency);

            return(dependency);
        }
Пример #7
0
        /// <summary>
        /// Registers a configured dependency for the dependencyType
        /// </summary>
        /// <param name="dependencyType"></param>
        /// <param name="dependency"></param>
        public void Dependency(Type dependencyType, ObjectDef dependency)
        {
            var configuredDependency = new ConfiguredDependency(dependencyType, dependency);

            Dependency(configuredDependency);
        }
Пример #8
0
 /// <summary>
 /// Registers a configured dependency of type T
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="dependency"></param>
 public void DependencyByType <T>(ObjectDef dependency)
 {
     Dependency(typeof(T), dependency);
 }
Пример #9
0
 /// <summary>
 /// Add a separately configured ObjectDef to the list or enumeration
 /// </summary>
 /// <param name="objectDef"></param>
 public void Add(ObjectDef objectDef)
 {
     objectDef.ValidatePluggabilityTo(ElementType);
     _items.Add(objectDef);
 }
Пример #10
0
 public static ConfiguredDependency For <TDependency, TConcrete>() where TConcrete : TDependency
 {
     return(new ConfiguredDependency(typeof(TDependency), ObjectDef.ForType <TConcrete>()));
 }
Пример #11
0
 public ConfiguredDependency(Type dependencyType, object value) : this(dependencyType, ObjectDef.ForValue(value))
 {
 }