示例#1
0
        public void Demonstrate()
        {
            Sample s = new Sample();

            s.DoSomething('z');
            s.DoSomething((byte)5);
            s.DoSomething(6.3333d);
            s.DoSomething(777);

            GenericA xa = s.GetSomething <GenericA>();
            GenericB xb = s.GetSomething <GenericB>();
        }
示例#2
0
        public void IsIEnumerableOfType_Generic()
        {
            var source = new GenericB <C>[]
            {
                new GenericB <C>(),
                new TestClass()
            };

            //var result = source.OfType<GenericB<C>>();
            var result = source.OfType((GenericType)typeof(GenericB <>));

            Assert.That(result, Is.EqualTo(source));
        }
示例#3
0
        public void IsOfType_Generic2()
        {
            var obj = new GenericB <C>();

            Assert.IsTrue(obj.IsSubclassOf((GenericType)typeof(GenericB <C>)));
            Assert.IsTrue(obj.IsSubclassOf((GenericType)typeof(GenericB <B>)));
            Assert.IsTrue(obj.IsSubclassOf((GenericType)typeof(GenericB <A>)));
            Assert.IsTrue(obj.IsSubclassOf((GenericType)typeof(GenericA <C>)));
            Assert.IsTrue(obj.IsSubclassOf((GenericType)typeof(GenericA <B>)));
            Assert.IsTrue(obj.IsSubclassOf((GenericType)typeof(GenericA <A>)));
            Assert.IsTrue(obj.IsSubclassOf(new GenericType(typeof(GenericB <>))));
            Assert.IsTrue(obj.IsSubclassOf(new GenericType(typeof(GenericA <>))));
        }
 public void Set(GenericB t2Value)
 {
     PropT2 = t2Value;
 }
 public HaveManyGenericTypesClosed(GenericB t2Value, GenericA t1Value)
 {
     PropT2 = t2Value;
     PropT1 = t1Value;
 }
 public HaveManyGenericTypesClosed(GenericB t2Value)
 {
     PropT2 = t2Value;
 }
示例#7
0
 public void Set(GenericB t2Value)
 {
     PropT2 = t2Value;
 }
示例#8
0
 public HaveManyGenericTypesClosed(GenericB t2Value, GenericA t1Value)
 {
     PropT2 = t2Value;
     PropT1 = t1Value;
 }
示例#9
0
 public HaveManyGenericTypesClosed(GenericB t2Value)
 {
     PropT2 = t2Value;
 }