Example #1
0
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888

            IBasicLoggingInitializer loggingInitializer = new Log4NetLoggingInitializer();
            app.UseMvcInitialize(new MvcInitializeOptions(loggingInitializer, new MvcAutofacIocInitializer()));
            app.UseWebApiInitialize(new WebApiInitializeOptions(loggingInitializer, new WebApiAutofacIocInitializer()));

            ConfigurationWebApi(app);
            ConfigureSignalR(app);
        }
Example #2
0
        private static void Initialize()
        {
            ICacheProvider provider = new RuntimeMemoryCacheProvider();
            CacheManager.SetProvider(provider, CacheLevel.First);

            IBasicLoggingInitializer loggingInitializer = new Log4NetLoggingInitializer();
            //Mvc初始化
            MvcInitializeOptions mvcOptions = new MvcInitializeOptions(loggingInitializer, new MvcAutofacIocInitializer());
            IFrameworkInitializer initializer = new MvcFrameworkInitializer(mvcOptions);
            initializer.Initialize();

            //WebApi初始化
            WebApiInitializeOptions apiOptions = new WebApiInitializeOptions(loggingInitializer, new WebApiAutofacIocInitializer());
            initializer = new WebApiFrameworkInitializer(apiOptions);
            initializer.Initialize();

            ////SignalR初始化
            //SignalRInitializeOptions signalrOptions = new SignalRInitializeOptions(loggingInitializer, new SignalRAutofacIocInitializer());
            //initializer = new SignalRFrameworkInitializer(signalrOptions);
            //initializer.Initialize();
        }
Example #3
0
        private static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("正在初始化,请稍候……");
                Stopwatch watch = Stopwatch.StartNew();

                Log4NetLoggingInitializer loggingInitializer = new Log4NetLoggingInitializer();
                ConsolesAutofacInitializer iocInitializer = new ConsolesAutofacInitializer();
                LocalInitializeOptions options = new LocalInitializeOptions(loggingInitializer, iocInitializer);
                IFrameworkInitializer initializer = new LocalFrameworkInitializer(options);
                initializer.Initialize();

                _program = iocInitializer.Resolver.Resolve<Program>();
                watch.Stop();
                Console.WriteLine("程序初始化完毕并启动成功,耗时:{0}", watch.Elapsed);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.FormatMessage());
                Console.ReadLine();
                return;
            }
            bool exit = false;
            while (true)
            {
                try
                {
                    Console.WriteLine(@"请输入命令:0; 退出程序,功能命令:1 - n");
                    string input = Console.ReadLine();
                    if (input == null)
                    {
                        continue;
                    }
                    switch (input.ToLower())
                    {
                        case "0":
                            exit = true;
                            break;
                        case "1":
                            Method01();
                            break;
                        case "2":
                            Method02();
                            break;
                        case "3":
                            Method03();
                            break;
                        case "4":
                            Method04();
                            break;
                        case "5":
                            Method05();
                            break;
                        case "6":
                            Method06();
                            break;
                        case "7":
                            Method07();
                            break;
                        case "8":
                            Method08();
                            break;
                        case "9":
                            Method09();
                            break;
                        case "10":
                            Method10();
                            break;
                        case "11":
                            Method11();
                            break;
                        case "12":
                            Method12();
                            break;
                        case "13":
                            Method13();
                            break;
                        case "14":
                            Method14();
                            break;
                        case "15":
                            Method15();
                            break;
                        case "16":
                            Method16();
                            break;
                        case "17":
                            Method17();
                            break;
                        case "18":
                            Method18();
                            break;
                    }
                    if (exit)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.FormatMessage());
                }
            }
        }