CreateFromKey() public méthode

Creates an instance of the behavior Type that is registered using the specified key.
public CreateFromKey ( string key ) : IRegionBehavior
key string The key that is used to register a behavior type.
Résultat IRegionBehavior
        public void CanCreateRegisteredType()
        {
            var expectedBehavior = new MockRegionBehavior();

            RegionBehaviorFactory factory = new RegionBehaviorFactory(new MockServiceLocator() { GetInstance = (t) => expectedBehavior });

            factory.AddIfMissing("key1", typeof(MockRegionBehavior));
            var behavior = factory.CreateFromKey("key1");

            Assert.AreSame(expectedBehavior, behavior);
        }
        public void CreateWithUnknownKeyThrows()
        {
            RegionBehaviorFactory factory = new RegionBehaviorFactory(null);

            Assert.ThrowsException<ArgumentException>(() => factory.CreateFromKey("Key1"));
        }
        public void CreateWithUnknownKeyThrows()
        {
            RegionBehaviorFactory factory = new RegionBehaviorFactory(null);

            factory.CreateFromKey("Key1");
        }