1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | private static DataTable GetConvertTable() { DataTable table = new DataTable(); DataColumnCollection cols = table.Columns; cols.Add("ClassName", typeof(string)); cols.Add("ObjectName", typeof(string)); cols.Add("Value", typeof(string)); return table; } public static DataTable GetClassField(string dllName, string className, Type type) { DataTable table = GetConvertTable(); try { string fullName = string.Format(@"{0}.Views.{1}", dllName, className); System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(string.Format(@".\{0}.dll", dllName)); System.Type classType = assembly.GetType(fullName); //Simple.Framework.UI.Checkup.Views.Request2 //Simple.Framework.UI.CheckUp.Views.Request2 //{Name = "Request2" FullName = "Simple.Framework.UI.CheckUp.Views.Request2"} var objClass = Activator.CreateInstance(classType); Type t = objClass.GetType(); // Instance fields. FieldInfo[] fi = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); foreach (FieldInfo f in fi.ToList()) { var fieldValue = f.GetValue(objClass); if (fieldValue != null) { //LabelControl if (fieldValue.GetType() == typeof(DevExpress.XtraEditors.LabelControl) && fieldValue.GetType() == type) { table.TableName = "LabelControl"; DataRow row = table.NewRow(); row["ClassName"] = fullName; row["ObjectName"] = ((DevExpress.XtraEditors.LabelControl)fieldValue).Name; row["Value"] = ((DevExpress.XtraEditors.LabelControl)fieldValue).Text; table.Rows.Add(row); } //ComboBoxEdit else if (fieldValue.GetType() == typeof(DevExpress.XtraEditors.ComboBoxEdit) && fieldValue.GetType() == type) { } //LookUpEdit else if (fieldValue.GetType() == typeof(DevExpress.XtraEditors.LookUpEdit) && fieldValue.GetType() == type) { } //SimpleGrid else if (fieldValue.GetType() == type) { } } } } catch (Exception ex) { //ExceptionMessage.ShowExceptionMessage(ex); } return table; } | cs |
'C#' 카테고리의 다른 글
06# 네트워크 활성화/비활성화 (0) | 2016.05.11 |
---|---|
05# 소켓 비동기식 처리 (0) | 2016.04.18 |
04# 속성(Property) 객체 생성 시 초기화 (0) | 2016.04.18 |
02#INI 파일 읽기 쓰기 (0) | 2016.04.18 |
01# 공유메모리를 통한 프로그램 호출, 종료, 메시지 전송 (0) | 2016.04.18 |