Example #1
0
        public void Init()
        {
            var registry = new StructureMap.Registry();

            //registry.IncludeRegistry<PasswordManagerRegistry>();
            _container = new Container(registry);
        }
Example #2
0
        private static Container ConfigureContainer()
        {
            var registry = new StructureMap.Registry();

            registry.IncludeRegistry <RulesRegistry>();
            registry.IncludeRegistry <ImportRegistry>();
            registry.IncludeRegistry <DefaultRegistry>();
            var container = new Container(registry);

            return(container);
        }
Example #3
0
        public void Start()
        {
            // I am namespacing one-off uses of the Shuttle.* framework to make it readily
            // apparent at what stages I am interacting with classes made available from the
            // use of the library.
            var structureMapRegistry          = new StructureMap.Registry();
            var structureMapComponentRegistry = new Shuttle.Core.StructureMap.StructureMapComponentRegistry(structureMapRegistry);

            Shuttle.Esb.ServiceBus.Register(structureMapComponentRegistry);

            this._serviceBus = Shuttle.Esb.ServiceBus.Create(
                new StructureMapComponentResolver(
                    new Container(structureMapRegistry)
                    )
                ).Start();
        }
Example #4
0
 public void ScanTypes(StructureMap.Graph.Scanning.TypeSet types, StructureMap.Registry registry)
 {
 }
        private void GetStructureMapConfig(ConfigurationExpression cfg)
        {
            cfg.For <IWindowManager>().Use <WindowManager>().Singleton();
            cfg.For <IEventAggregator>().Use <EventAggregator>().Singleton();
            cfg.For <ILogger>().Singleton().Use <Logger>();


            var exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (exeDir != null)
            {
                var modDir = Path.Combine(exeDir, "Modules");

                var registry = new Registry();


                #region MediatR registry

                // ------- START MediatR Configure -----------------------

                // INFO: Пока в этом сканере нет необходимости

                /*
                 * // используем внешний mediator pattern
                 * registry.Scan(scanner =>
                 * {
                 *  scanner.TheCallingAssembly();
                 *  //scanner.Assembly(this.GetType().Assembly); // ?
                 *  scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler<>)); // Handlers with no response
                 *  scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler<,>)); // Handlers with a response
                 *  scanner.ConnectImplementationsToTypesClosing(typeof(IAsyncRequestHandler<>)); // Async handlers with no response
                 *  scanner.ConnectImplementationsToTypesClosing(typeof(IAsyncRequestHandler<,>)); // Async Handlers with a response
                 *  scanner.ConnectImplementationsToTypesClosing(typeof(INotificationHandler<>));
                 *  scanner.ConnectImplementationsToTypesClosing(typeof(IAsyncNotificationHandler<>));
                 * });
                 */

                // Scan other assembly modules Regisry Types with DLL like name *Extension.dll
                registry.Scan(scanner =>
                {
                    if (Directory.Exists(modDir))
                    {
                        //  More examples Scan:
                        // https://github.com/structuremap/structuremap/blob/master/src/StructureMap.Testing/Examples.cs
                        scanner.AssembliesFromPath(modDir, assembly => assembly.GetName().Name.Contains("Extension"));
                    }

                    scanner.WithDefaultConventions();
                    // Если есть, автоматичесски запускать регистрацию классов производных от Registry
                    scanner.LookForRegistries();
                    //canner.Convention<ViewRegistrationConvention>();
                });

                //registry.For<SingleInstanceFactory>().Use<SingleInstanceFactory>(ctx => t => ctx.GetInstance(t));
                //registry.For<MultiInstanceFactory>().Use<MultiInstanceFactory>(ctx => t => ctx.GetAllInstances(t));
                //registry.For<IMediator>().Use<Mediator>();

                // ------- END MediatR Configure -----------------------

                #endregion

                registry.IncludeRegistry <SheduleConfigRegistry>();
                registry.IncludeRegistry <SystemTrayIconRegistry>();

                cfg.AddRegistry(registry);
            }
        }
Example #6
0
 public PluginGraphBuilder Add(Registry registry)
 {
     _graph.ImportRegistry(registry);
     return(this);
 }
Example #7
0
 public Container(Registry registry)
     : this(registry.Build())
 {
 }
Example #8
0
 public Container(Registry registry)
     : this(new PluginGraphBuilder().Add(registry).Build())
 {
 }