示例#1
0
        public void BuildUp(object target)
        {
            var pluggedType = target.GetType();
            var instance    = _pipelineGraph.GetDefault(pluggedType) as IConfiguredInstance
                              ?? new ConfiguredInstance(pluggedType);

            // TODO -- do this by pulling SetterRules out of PluginGraph
            var builder   = _pipelineGraph.Outer.BuilderFor(pluggedType);
            var arguments = new Arguments(instance, this);

            builder.BuildUp(arguments, target);
        }
示例#2
0
        public object TryGetDefault(Type pluginType, IPipelineGraph pipelineGraph)
        {
            if (_defaults.ContainsKey(pluginType))
            {
                return(_defaults[pluginType]);
            }

            var instance = pipelineGraph.GetDefault(pluginType);

            if (instance == null)
            {
                return(null);
            }

            var o = GetObject(pluginType, instance);

            _defaults.Add(pluginType, o);

            return(o);
        }
示例#3
0
        public object GetDefault(Type pluginType, IPipelineGraph pipelineGraph)
        {
            if (_defaults.ContainsKey(pluginType))
            {
                return(_defaults[pluginType]);
            }

            var instance = pipelineGraph.GetDefault(pluginType);

            if (instance == null)
            {
                throw new StructureMapException(202, pluginType);
            }


            var o = GetObject(pluginType, instance);

            if (!instance.IsUnique())
            {
                _defaults.Add(pluginType, o);
            }

            return(o);
        }
示例#4
0
 public Instance GetDefault(Type pluginType)
 {
     return(_outer.HasDefaultForPluginType(pluginType)
                ? _outer.Families[pluginType].GetDefaultInstance()
                : _parent.GetDefault(pluginType));
 }