Пример #1
0
 /// <summary>
 /// 初始化Mvc框架
 /// </summary>
 public static IAppBuilder UseOSkyMvc(this IAppBuilder app, IServiceCollection services, IIocBuilder iocBuilder)
 {
     services.CheckNotNull("services");
     iocBuilder.CheckNotNull("iocBuilder");
     IFrameworkInitializer initializer = new FrameworkInitializer();
     initializer.Initialize(services, iocBuilder);
     return app;
 }
Пример #2
0
        private static void Initialize()
        {
            ICacheProvider provider = new RuntimeMemoryCacheProvider();
            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder builder = new ServicesBuilder(new ServiceBuildOptions());
            IServiceCollection services = builder.Build();
            services.AddLog4NetServices();
            services.AddDataServices();

            IFrameworkInitializer initializer = new FrameworkInitializer();

            initializer.Initialize(services, new MvcAutofacIocBuilder());
            initializer.Initialize(services, new WebApiAutofacIocBuilder());
            initializer.Initialize(services, new SignalRAutofacIocBuilder());
        }
Пример #3
0
        private static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("正在初始化,请稍候……");
                Stopwatch watch = Stopwatch.StartNew();

                IServicesBuilder builder = new ServicesBuilder(new ServiceBuildOptions());
                IServiceCollection services = builder.Build();
                services.AddLog4NetServices();
                services.AddDataServices();
                ConsolesAutofacBuilder iocBuilder = new ConsolesAutofacBuilder();
                IFrameworkInitializer initializer = new FrameworkInitializer();
                initializer.Initialize(services, iocBuilder);

                _program = iocBuilder.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());
                }
            }
        }