public Initialize ( IIocBuilder iocBuilder ) : void | ||
iocBuilder | IIocBuilder | 依赖注入构建器 |
Результат | void |
private static void Initialize() { IServicesBuilder builder = new ServicesBuilder(); IServiceCollection services = builder.Build(); services.AddLog4NetServices(); services.AddDataServices(); services.AddAutoMapperServices(); IFrameworkInitializer initializer = new FrameworkInitializer(); initializer.Initialize(new MvcAutofacIocBuilder(services)); initializer.Initialize(new WebApiAutofacIocBuilder(services)); //initializer.Initialize(new SignalRAutofacIocBuilder(services)); }
private static void Initialize() { ICacheProvider provider = new RuntimeMemoryCacheProvider(); CacheManager.SetProvider(provider, CacheLevel.First); IServicesBuilder builder = new ServicesBuilder(); IServiceCollection services = builder.Build(); services.AddLog4NetServices(); services.AddDataServices(); IFrameworkInitializer initializer = new FrameworkInitializer(); initializer.Initialize(new MvcAutofacIocBuilder(services)); initializer.Initialize(new WebApiAutofacIocBuilder(services)); //initializer.Initialize(new SignalRAutofacIocBuilder(services)); }
/// <summary> /// 初始化本地程序集框架 /// </summary> public static IAppBuilder UseLocalInitialize(this IAppBuilder app, IIocBuilder iocBuilder) { iocBuilder.CheckNotNull("iocBuilder" ); IFrameworkInitializer initializer = new FrameworkInitializer(); initializer.Initialize(iocBuilder); return app; }
/// <summary> /// 初始化Mvc框架 /// </summary> public static IAppBuilder UseOsharpMvc(this IAppBuilder app, IServiceCollection services, IIocBuilder iocBuilder) { services.CheckNotNull("services"); iocBuilder.CheckNotNull("iocBuilder"); IFrameworkInitializer initializer = new FrameworkInitializer(); initializer.Initialize(services, iocBuilder); return app; }
/// <summary> /// 初始化Mvc框架 /// </summary> public static IAppBuilder UseOsharpMvc(this IAppBuilder app, IIocBuilder iocBuilder) { iocBuilder.CheckNotNull("iocBuilder"); ModelBinders.Binders.Add(typeof(string), new StringTrimModelBinder()); IFrameworkInitializer initializer = new FrameworkInitializer(); initializer.Initialize(iocBuilder); return app; }
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(); services.AddAutoMapperServices(); IIocBuilder iocBuilder = new LocalAutofacIocBuilder(services); IFrameworkInitializer initializer = new FrameworkInitializer(); initializer.Initialize(iocBuilder); _program = iocBuilder.ServiceProvider.GetService<Program>(); watch.Stop(); Console.WriteLine("程序初始化完毕并启动成功,耗时:{0}", watch.Elapsed); } catch (ReflectionTypeLoadException e) { Console.WriteLine(e); Console.WriteLine("LoaderExceptions:"); Exception[] exs = e.LoaderExceptions; foreach (Exception ex in exs) { Console.WriteLine(ex); } return; } catch (Exception e) { Console.WriteLine(e); 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()); } } }