示例#1
0
        public void TestGetSingletonWithManualInstantiation()
        {
            MyServiceWithNoDependencies myService = new MyServiceWithNoDependencies();

            IServiceProvider serviceProvider = new ServiceCollection()
                                               .AddSingleton <IMyService>(myService)
                                               .BuildServiceProvider();

            Assert.IsTrue(serviceProvider.GetService <IMyService>().Equals(myService));
        }
示例#2
0
 public MyServiceWithMultipleConstructorsAndOptionalDependencies(MyServiceWithNoDependencies service1 = null, MyServiceWithNoDependencies service2 = null)
 {
     InvokedConstructorId = 2;
 }
示例#3
0
 public MyServiceWithMultipleConstructorsWithActivatorUtilitiesConstructor(MyServiceWithNoDependencies service)
 {
 }
示例#4
0
 public MyServiceWithMultipleConstructors(MyServiceWithNoDependencies service)
 {
 }
示例#5
0
 public MyServiceWithOptionalDependencies(MyServiceWithNoDependencies service = null)
 {
 }
示例#6
0
 public MyServiceWithDependencies(MyServiceWithNoDependencies service)
 {
 }