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

AreAllTypesRegistered() public method

Determines whether all the specified types are registered with the service locator.
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 IsTypeRegistered instead.
The is null.
public AreAllTypesRegistered ( ) : bool
return bool
        public bool AreAllTypesRegistered(params Type[] types)
        {
            Argument.IsNotNull("types", types);

            lock (_lockObject)
            {
                // Note: do NOT rewrite as linq because that is much slower
                // ReSharper disable LoopCanBeConvertedToQuery
                foreach (var type in types)
                // ReSharper restore LoopCanBeConvertedToQuery
                {
                    if (!IsTypeRegistered(type))
                    {
                        return false;
                    }
                }

                return true;
            }
        }

Usage Example

コード例 #1
0
ファイル: ServiceLocatorFacts.cs プロジェクト: pars87/Catel
            public void ReturnsFalseWhenAtLeastOneTypeIsNotRegistered()
            {
                var serviceLocator = new ServiceLocator();

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

                Assert.IsFalse(serviceLocator.AreAllTypesRegistered(typeof(object), typeof(ITestInterface1), typeof(ITestInterface2)));
            }
All Usage Examples Of Catel.IoC.ServiceLocator::AreAllTypesRegistered