コード例 #1
0
        public void TryGet()
        {
            var provider = new FactoryProvider();

            provider.Add(new FactoryCollection <int>());

            bool result1 = provider.TryGet(typeof(int), out IFactoryCollection collection1);
            bool result2 = provider.TryGet(typeof(long), out IFactoryCollection collection2);

            Assert.True(result1);
            Assert.False(result2);
            Assert.NotNull(collection1);
            Assert.Null(collection2);
        }
コード例 #2
0
        public void TryGetGeneric()
        {
            var provider = new FactoryProvider();

            provider.Add(new FactoryCollection <int>());

            bool result1 = provider.TryGet(out IFactoryCollection <int> collection1);
            bool result2 = provider.TryGet(out IFactoryCollection <long> collection2);

            Assert.True(result1);
            Assert.False(result2);
            Assert.NotNull(collection1);
            Assert.Null(collection2);
        }