Esempio n. 1
0
        public void ConfigureMyServices(IMyServiceCollection services)
        {
            // 线程间共享
            services.AddScoped <IMain, Main>();
            services.AddScoped <IThreadA, ThreadA>();
            services.AddScoped <IThreadB, ThreadB>();

            // 单例
            services.AddSingleton <IThreadC, ThreadC>();

            //// 临时
            //services.AddTransient<IThreadC, ThreadC>();
        }
Esempio n. 2
0
 public static void AddSingleton <T1, T2>(this IMyServiceCollection services) where T2 : T1
 {
     serviceTypes.Add(typeof(T1), MyServiceDescriptor.Singleton(typeof(T2)));
 }
Esempio n. 3
0
 public static void AddSingleton <T1>(this IMyServiceCollection services)
 {
     serviceTypes.Add(typeof(T1), MyServiceDescriptor.Singleton(typeof(T1)));
 }
Esempio n. 4
0
 public static void AddTransient <T1, T2>(this IMyServiceCollection services) where T2 : T1
 {
     serviceTypes.Add(typeof(T1), MyServiceDescriptor.Transient(typeof(T2)));
 }
Esempio n. 5
0
 public static void AddTransient <T1>(this IMyServiceCollection services)
 {
     serviceTypes.Add(typeof(T1), MyServiceDescriptor.Transient(typeof(T1)));
 }