public void 泛型类_已定义参数类型() { Type type = typeof(Model_泛型1 <int, double, int>); Assert.Equal("<int, double, int>", "<" + string.Join(",", GenericeAnalysis.GetGenriceParams(type)) + ">"); //Assert.Equal("<System.Int32, System.Double, System.Int32>", GenericeAnalysis.Analysis(type, true)); }
public void 子类非泛型_父类泛型已定义解析() { Type type = new Model_泛型3().GetType(); Assert.Equal("<int, double, int>", "<" + string.Join(",", GenericeAnalysis.GetGenriceParams(type)) + ">"); //Assert.Equal("<System.Int32, System.Double, System.Int32>", "<"+string.Join(",", GenericeAnalysis.GetGenriceParams(type))+">"); }
public void 泛型类_未定义参数类型() { Type type = typeof(Model_泛型1 <, ,>); Assert.Equal("<, , >", "<" + string.Join(",", GenericeAnalysis.GetGenriceParams(type)) + ">"); //Assert.Equal("<T1, T2, T3>", GenericeAnalysis.Analysis(type, true)); }
public void 泛型方法原名称() { Type type = typeof(Test); MethodInfo methodInfo = type.GetMethod("A"); Assert.Equal("A", GenericeAnalysis.WipeOutName(methodInfo.Name)); }
public void 泛型类原名称() { Type type = typeof(Model_泛型1 <, ,>); Assert.Equal("Model_泛型1", GenericeAnalysis.GetOriginName(type)); Assert.Equal("Model_泛型1", GenericeAnalysis.WipeOutName(type.Name)); }
public void 子类非泛型_父类泛型已定义解析() { Type type = new Model_泛型3().GetType(); Assert.Equal("<>", "<" + string.Join(",", GenericeAnalysis.GetGenriceParams(type)) + ">"); Assert.Equal("<int,double,int>", "<" + string.Join(",", GenericeAnalysis.GetGenriceParams(typeof(Model_泛型1 <int, double, int>))) + ">"); }
public void 泛型类_泛型父类解析() { Model_泛型2 <int, double, int> model_ = new Model_泛型2 <int, double, int>(); Type type = model_.GetType(); Assert.Equal("<int, double, int>", "<" + string.Join(",", GenericeAnalysis.GetGenriceParams(type)) + ">"); //Assert.Equal("<System.Int32, System.Double, System.Int32>", GenericeAnalysis.Analysis(type.BaseType, true)); }
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)); }
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)); }
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)); }
public void 长嵌套泛型泛型定义() { Type type = typeof(Model_泛型1 <int, List <int>, Dictionary <List <int>, Dictionary <int, List <int> > > >); string output = GenericeAnalysis.GetGenriceName(type); _tempOutput.WriteLine(output); Assert.Equal("Model_泛型1<int, List<int>, Dictionary<List<int>, Dictionary<int, List<int>>>>", output); }
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)); }
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)); }
public void 超复杂的泛型约束() { Type type = typeof(Model_泛型类5 <, , , , , , , , , ,>); _tempOutput.WriteLine(GenericeAnalysis.GetGetConstrainCode(type, true)); Assert.Equal(@"where T1 : struct where T2 : class where T3 : notnull where T4 : struct where T5 : new() where T6 : Model_泛型类4 where T7 : IEnumerable<int> where T8 : T2 where T9 : class,notnull,new() where T10 : Model_泛型类4,IEnumerable<int>,new() ", GenericeAnalysis.GetGetConstrainCode(type, true)); }
public void 长嵌套泛型参数解析() { Type type = typeof(Model_泛型1 <int, List <int>, Dictionary <List <int>, Dictionary <int, List <int> > > >); Assert.Equal("<int, List<int>, Dictionary<List<int>, Dictionary<int, List<int>>>>", "<" + string.Join(",", GenericeAnalysis.GetGenriceParams(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)); }