Catel.IoC.ServiceLocator.ResolveAllTypes C# (CSharp) Method

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[]
        public object[] ResolveAllTypes(params Type[] types)
        {
            Argument.IsNotNull("types", types);

            lock (_lockObject)
            {
                // Note: do NOT rewrite as linq because that is much slower
                var values = new List<object>();
                // ReSharper disable LoopCanBeConvertedToQuery
                foreach (var type in types)
                // ReSharper restore LoopCanBeConvertedToQuery
                {
                    var resolvedType = ResolveType(type);
                    values.Add(resolvedType);
                }

                return values.ToArray();
            }
        }

Usage Example

コード例 #1
0
ファイル: ServiceLocatorFacts.cs プロジェクト: pars87/Catel
            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)));
            }
All Usage Examples Of Catel.IoC.ServiceLocator::ResolveAllTypes