public void GetMemberInfoTest() { // 225 to 25 ms to5 for (int i = 0; i < MaxTime; i++) { var mem = CTRCHelper.GetMemberInfos <MethodModel>().FirstOrDefault(c => c.Name == "Test1"); } }
public void MyTestMethod() { var stopwatch = new Stopwatch(); stopwatch.Start(); var dict = CTRCHelper.GetMethodInfos <MethodModel>() .ToDictionary(c => c, t => new Dictionary <string, Func <int, int> > { { "a", (i) => i + 12 }, { "b", (i) => i + 12 }, { "c", (i) => i + 12 }, { "d", (i) => i + 12 }, { "e", (i) => i + 12 } }); var key = CTRCHelper.GetMethodInfos <MethodModel>().LastOrDefault(c => c.Name == "Generic"); Console.WriteLine(dict.Count); Console.WriteLine(stopwatch.ElapsedMilliseconds); var d = EqualityComparer <MethodInfo> .Default; for (int i = 0; i < MaxTime; i++) { // var t= d.GetHashCode(key); //var t = key.Equals(dict.Keys.First()); var t = dict[key]["a"]; } Console.WriteLine(stopwatch.ElapsedMilliseconds); }
public void GetMemberInfosTest() { // 225 to 25 ms to5 for (int i = 0; i < MaxTime; i++) { var mem = CTRCHelper.GetMemberInfos <MethodModel>(); } }
public void GetMethodInfosTest() { //60ms 2 11ms for (int i = 0; i < MaxTime; i++) { var mem = CTRCHelper.GetMethodInfos <MethodModel>(); } }
public void GetPropertyTest() { var props = CTRCHelper.GetPropertiesCache <PropertyTestModel>(); foreach (var propertyInfo in props) { Console.WriteLine(propertyInfo.Name); } Assert.AreEqual(1, props.Length); }
public void GetDifferentMemberInfosTest() { var t = CTRCHelper.GetMemberInfos <MethodModel>(); Console.WriteLine(t); var t1 = CTRCHelper.GetMemberInfos <FieldModel>(); Console.WriteLine(t1); }
public void GetFieldInfosTest() { for (int i = 0; i < MaxTime; i++) { // var t= typeof(MyClass).GetFields(); var t = CTRCHelper.GetFieldInfos <MethodModel>(); //var t = string.Empty; } }
public void MethodCountTest() { var methods = CTRCHelper.GetMethodInfos <MethodTestModel>(); foreach (var m in methods) { Console.WriteLine(m.Name); } Assert.AreEqual(3, methods.Length); }
public void GetExecutingAssemblyVersionTest() { var stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < MaxTime; i++) { var b = CTRCHelper.GetExecutingAssemblyVersion(); } Console.WriteLine(stopwatch.ElapsedMilliseconds); }
public void TestMethod1() { var fields = CTRCHelper.GetFieldInfos <TestEnum>(); //Console.WriteLine(fields.Length); foreach (var field in fields) { // if (field.Name == "value__") continue; // Console.WriteLine(Enum.Parse(typeof(TestEnum), field.Name)); var t = CTRCHelper.GetCustomAttributes <DescriptionAttribute>(field); //Console.WriteLine(t?.Description??"none"); } }
/// <summary> /// Get the ExcelTitleAttribute on proerties /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static Dictionary <PropertyInfo, ExcelTitleAttribute> GetPropertiesAttributesDict <T>() { var dict = new Dictionary <PropertyInfo, ExcelTitleAttribute>(); int defaultOrder = 10000; foreach (var propertyInfo in CTRCHelper.GetPropertiesCache <T>()) { var attrs = propertyInfo.GetCustomAttributes(true); var attr = GetExcelTitleAttributeFromAttributes(attrs, defaultOrder++); if (attr == null) { continue; } dict.Add(propertyInfo, attr); } return(dict); }