// lay ra mot mang cac value ung voi mang PropertyInfo public object[] GetPropertyValues(DBEntry entry,PropertyInfo[] PInfors) { int count=0; object[] CatchLists=new object[PInfors.Length]; try { foreach (PropertyInfo Pi in PInfors) { CatchLists[count]=GetPropertyValue(entry,Pi); count++; } } catch (Exception EX) { Except.SetException(EX); } return CatchLists; }
// Chi nhung thuoc tinh ung voi cac Field cua DBEntry public PropertyInfo[] GetFilterProperties(DBEntry entry) { PropertyInfo[] ListObject=new PropertyInfo[entry.FieldCount]; PropertyInfo[] Properties=GetAllProperties(entry); string[] ListFields=entry.GetListFields(); string[] AllListNames=GetPropertyNames(Properties); try { for (int count=0;count<ListFields.Length;count++) { for (int i=0;i<AllListNames.Length;i++) { if (ListFields[count].ToLower()==AllListNames[i].ToLower()) { ListObject[count]=Properties[i]; break; } else { continue; } } } } catch (Exception EX) { Except.SetException(EX); } return ListObject; }
// Lay mot gia tri cua 1 thuoc tinh nao do trong Entry public object GetPropertyValue(DBEntry entry,PropertyInfo Pinfo) { object Catchvalue=null; object[] Attributes=Pinfo.GetCustomAttributes(typeof(DBPropertyAttribute),false); if (Attributes.Length==1) { try { MethodInfo Mi=Pinfo.GetGetMethod(false); object result=Mi.Invoke(entry,null); Catchvalue=result; } catch (Exception EX) { Except.SetException(EX); } } return Catchvalue; }
// All Property ung voi cac Field cua DBEntry public PropertyInfo[] GetAllProperties(DBEntry entry) { Type T=entry.GetType(); PropertyInfo[] Properties=T.GetProperties(BindingFlags.DeclaredOnly|BindingFlags.Instance|BindingFlags.Public); return Properties; }