コード例 #1
0
        public void 泛型类_已定义参数类型()
        {
            Type             type             = typeof(Model_泛型1 <int, double, int>);
            GenericeAnalysis genericeAnalysis = new GenericeAnalysis();

            Assert.Equal("<int, double, int>", genericeAnalysis.Analysis(type));
            Assert.Equal("<System.Int32, System.Double, System.Int32>", genericeAnalysis.Analysis(type, true));
        }
コード例 #2
0
        public void 子类非泛型_父类泛型已定义解析()
        {
            Type             type             = new Model_泛型3().GetType();
            GenericeAnalysis genericeAnalysis = new GenericeAnalysis();

            Assert.Equal("<int, double, int>", genericeAnalysis.Analysis(type.BaseType));
            Assert.Equal("<System.Int32, System.Double, System.Int32>", genericeAnalysis.Analysis(type.BaseType, true));
        }
コード例 #3
0
        public void 泛型类_泛型父类解析()
        {
            Model_泛型2 <int, double, int> model_ = new Model_泛型2 <int, double, int>();
            Type             type             = model_.GetType();
            GenericeAnalysis genericeAnalysis = new GenericeAnalysis();

            Assert.Equal("<int, double, int>", genericeAnalysis.Analysis(type.BaseType));
            Assert.Equal("<System.Int32, System.Double, System.Int32>", genericeAnalysis.Analysis(type.BaseType, true));
        }
コード例 #4
0
        public void 泛型类_未定义参数类型()
        {
            Type             type             = typeof(Model_泛型1 <, ,>);
            GenericeAnalysis genericeAnalysis = new GenericeAnalysis();
            var z = genericeAnalysis.Analysis(type);

            Assert.Equal("<, , >", genericeAnalysis.Analysis(type));
            Assert.Equal("<T1, T2, T3>", genericeAnalysis.Analysis(type, true));
        }
コード例 #5
0
        public void 长嵌套泛型参数解析()
        {
            Type             type             = typeof(Model_泛型1 <int, List <int>, Dictionary <List <int>, Dictionary <int, List <int> > > >);
            GenericeAnalysis genericeAnalysis = new GenericeAnalysis();

            Assert.Equal("<int, List<int>, Dictionary<List<int>, Dictionary<int, List<int>>>>", genericeAnalysis.Analysis(type));
            Assert.Equal(@"<System.Int32, System.Collections.Generic.List<System.Int32>, System.Collections.Generic.Dictionary<System.Collections.Generic.List<System.Int32>, System.Collections.Generic.Dictionary<System.Int32, System.Collections.Generic.List<System.Int32>>>>", genericeAnalysis.Analysis(type, true));
        }