コード例 #1
0
        static void Main()
        {
            // Kick off the IoC container.
            // Initialize the service locator (InstanceFactory)
            InitializeNinject.StartUp();

            // Use this instead because of (bad design) the need to tell ninject
            // which constructor to use for IoC/DI. Found at:
            // http://stackoverflow.com/questions/8777475/whats-the-difference-between-toconstructor-and-tomethod-in-ninject-3
            // The following example was pulled from the DapperPlayground project.
            // It worked as needed until a much-needed refactoring took place which
            // removed the necessity for the following code:
            //IKernel vKernel = InitializeNinject.StartupAndReturnKernel();
            //vKernel
            //	.Rebind<ISqlServerConnectionFactory>()
            //	.ToConstructor<SqlServerConnectionFactory>
            //	(
            //		ctorArg =>
            //			new SqlServerConnectionFactoryNamedConnection(ctorArg.Inject<IAWESettings>())
            //	);

            // Instantiate the instance
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            mfIoCWinForm vForm = InstanceFactory.GetInstance <mfIoCWinForm>();

            Application.Run(vForm);
        }
コード例 #2
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            Kernel = InitializeNinject.Initialize(app, Configuration, RequestScope);
            InitializeDatabase.Initialize(Kernel, Configuration, RequestScope);
            InitializeServices.Initialize(Kernel);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseCors("DefaultCors");
            app.UseMvc();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Magic");
            });
        }
コード例 #3
0
        public static int Main(string[] args)
        {
            // Kick off the IoC container.
            // Initialize the service locator (InstanceFactory)
            InitializeNinject.StartUp();

            // Instantiate the instance
            ProgramIoCConsole vProgram = InstanceFactory.GetInstance <ProgramIoCConsole>();
            int vResult = vProgram.DoTheProgram(args);

            return(vResult);
        }
コード例 #4
0
        //--------------------------------------------------------------------------
        // Begin IoC methodology
        //--------------------------------------------------------------------------

        private static void StartUpIoC()
        {
            // Use this instead because of (bad design) the need to tell ninject
            // which constructor to use for IoC/DI. Found at:
            // http://stackoverflow.com/questions/8777475/whats-the-difference-between-toconstructor-and-tomethod-in-ninject-3

            // Kick off the IoC container.
            // Initialize the service locator (InstanceFactory)
            InitializeNinject.StartUp();

            // Instantiate the instance
            // Once again, we are forced to use a Bad Design (the "Service Locator"
            // pattern, but, also again, there is no other way to invoke IoC.
            _MainForm = InstanceFactory.GetInstance <mfIoCWinForm>();
        }
コード例 #5
0
        private static int DoItTheIoCWay(string[] args)
        {
            // Kick off the IoC container.
            // Initialize the service locator (InstanceFactory)
            InitializeNinject.StartUp();

            // Instantiate the instance
            // Normally, this is a Bad Practice. However, since there isn't an easier
            // way to jump start the IoC, the program needs to go get the initial
            // instance.
            ProgramIoCConsole vProgram =
                InstanceFactory.GetInstance <ProgramIoCConsole>();
            int vResult = vProgram.DoTheProgram(args);

            return(vResult);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            // Kick off the IoC container.
            // Initialize the service locator (InstanceFactory)
            InitializeNinject.StartUp();

            // Instantiate the instance
            // ServiceBase[] ServicesToRun;
            // ServicesToRun = new ServiceBase[] { new IoCService() };
            IoCService vService = InstanceFactory.GetInstance <IoCService>();

#if DEBUG
            if (Debugger.IsAttached && (args != null) && (args.Length > 0) && (args[0] == "-Console"))
            {
                vService.Timer_Elapsed(vService, null);
                return;
            }
#endif
            ServiceBase.Run(vService);
        }
コード例 #7
0
 // Must convert this from [TestFixtureSetUp] to constructor because if we
 // are using [TestCaseSource] (which fires BEFORE [TestFixtureSetUp])
 // this won't get executed in time.
 protected BASE_IntegrationTest()
 {
     InitializeNinject.StartUp();
     _TransactionScope = new TransactionScope();
     TablesToReseed    = new List <string>();
 }