ResolveAllTypes() public method

Resolves all the specified types.
Note that this method is written for optimalization by the TypeFactory. This means that the TypeFactory does not need to call the ServiceLocator several times to construct a single type using dependency injection. Only use this method if you know what you are doing, otherwise use the ResolveType instead.
The is null.
public ResolveAllTypes ( ) : object[]
return object[]
示例#1
0
            public void ThrowsNotSupportedExceptionWhenAtLeastOneTypeIsNotRegistered()
            {
                var serviceLocator = new ServiceLocator();

                serviceLocator.RegisterType<object>();
                serviceLocator.RegisterType<ITestInterface1, TestClass1>();

                ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => serviceLocator.ResolveAllTypes(typeof(object), typeof(ITestInterface1), typeof(ITestInterface2)));
            }
示例#2
0
            public void ReturnsAllTypesWhenAllAreRegistered()
            {
                var serviceLocator = new ServiceLocator();

                serviceLocator.RegisterInstance(new object());
                serviceLocator.RegisterType<ITestInterface1, TestClass1>();
                serviceLocator.RegisterType<ITestInterface2, TestClass2>();

                var resolvedTypes = serviceLocator.ResolveAllTypes(typeof(object), typeof(ITestInterface1), typeof(ITestInterface2)).ToArray();

                Assert.AreEqual(3, resolvedTypes.Length);
                Assert.AreEqual(typeof(object), resolvedTypes[0].GetType());
                Assert.AreEqual(typeof(TestClass1), resolvedTypes[1].GetType());
                Assert.AreEqual(typeof(TestClass2), resolvedTypes[2].GetType());
            }
示例#3
0
            public void ThrowsArgumentExceptionForNullOrEmptyTypeArray()
            {
                var serviceLocator = new ServiceLocator();

                ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => serviceLocator.ResolveAllTypes(null));
            }