AccidentalFish.ApplicationSupport.Core.Runtime.Implementation.ComponentFactory.Create C# (CSharp) Метод

Create() публичный Метод

public Create ( IComponentIdentity componentIdentity ) : IHostableComponent
componentIdentity IComponentIdentity
Результат IHostableComponent
        public IHostableComponent Create(IComponentIdentity componentIdentity)
        {
            try
            {
                return _container.Resolve<IHostableComponent>(componentIdentity.ToString());
            }
            catch (Exception)
            {
                return null;
            }
        }
    }

Usage Example

        public void UnregisteredThrowsException()
        {
            // Arrange
            var identity = new ComponentIdentity("hellonotfound");
            var hostableComponent = new Mock<IHostableComponent>();
            _dependencyResolver.Setup(x => x.Resolve<IHostableComponent>("hellonotfound")).Throws<Exception>();
            var factory = new ComponentFactory(_dependencyResolver.Object);

            // Act
            IHostableComponent result = factory.Create(identity);

            // Assert
            Assert.IsNull(result);
        }
All Usage Examples Of AccidentalFish.ApplicationSupport.Core.Runtime.Implementation.ComponentFactory::Create