예제 #1
0
        private void construct(PluginGraph pluginGraph)
        {
            _interceptorLibrary = pluginGraph.InterceptorLibrary;

            if (!pluginGraph.IsSealed)
            {
                pluginGraph.Seal();
            }

            _pluginGraph = pluginGraph;

            var thisInstance = new ObjectInstance(this);

            _pluginGraph.FindFamily(typeof(IContainer)).AddInstance(thisInstance);
            _pluginGraph.ProfileManager.SetDefault(typeof(IContainer), thisInstance);

            var funcInstance = new FactoryTemplate(typeof(LazyInstance <>));

            _pluginGraph.FindFamily(typeof(Func <>)).AddInstance(funcInstance);
            _pluginGraph.ProfileManager.SetDefault(typeof(Func <>), funcInstance);



            pluginGraph.Log.AssertFailures();

            _pipelineGraph = new PipelineGraph(pluginGraph);
        }
        public void SetUp()
        {
            graph    = new PluginGraph();
            pipeline = new PipelineGraph(graph);
            library  = new InterceptorLibrary();

            builder = new ObjectBuilder(pipeline, library);
        }
예제 #3
0
        public ObjectBuilder(PipelineGraph pipeline, InterceptorLibrary library)
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException("pipeline");
            }

            _pipeline = pipeline;
            _library  = library;
        }
        public void SetUp()
        {
            _interceptor1 = new MockTypeInterceptor(typeof(string));
            _interceptor2 = new MockTypeInterceptor(typeof(int), typeof(double));
            _interceptor3 = new MockTypeInterceptor(typeof(string), typeof(bool));
            _interceptor4 = new MockTypeInterceptor(typeof(string), typeof(double));

            _library = new InterceptorLibrary();
            _library.AddInterceptor(_interceptor1);
            _library.AddInterceptor(_interceptor2);
            _library.AddInterceptor(_interceptor3);
            _library.AddInterceptor(_interceptor4);
        }
        public void Import_from_gets_all_interceptors_and_resets_the_type_filter()
        {
            var sourceLibrary = new InterceptorLibrary();

            sourceLibrary.AddInterceptor(new MockTypeInterceptor(typeof(string)));
            sourceLibrary.FindInterceptor(typeof(string));

            var destinationLibrary = new InterceptorLibrary();

            destinationLibrary.AddInterceptor(new MockTypeInterceptor(typeof(string)));

            destinationLibrary.ImportFrom(sourceLibrary);

            InstanceInterceptor[] interceptors = destinationLibrary.FindInterceptors(typeof(string));
            Assert.AreEqual(2, interceptors.Length);
        }
예제 #6
0
        public BuildSession(PipelineGraph pipelineGraph, InterceptorLibrary interceptorLibrary)
        {
            _builder       = new ObjectBuilder(pipelineGraph, interceptorLibrary);
            _pipelineGraph = pipelineGraph;

            _defaults = new Cache <Type, Func <object> >(t =>
            {
                Instance instance = _pipelineGraph.GetDefault(t);

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

                return(() => CreateInstance(t, instance));
            });
        }
예제 #7
0
 public ValidationBuildSession(PipelineGraph pipelineGraph, InterceptorLibrary interceptorLibrary)
     : base(pipelineGraph, interceptorLibrary)
 {
 }