private void SetPropertyList(string[] nameList, string[] typeList, string[] valueList) { PropertyInfo[] pInfoList = GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo info in pInfoList) { if (info.CanRead && info.CanWrite) { int index = -1; for (int i = 0; i < nameList.Length; ++i) { if (nameList[i] == info.Name) { index = i; break; } } if (index < 0) { continue; } object obj = Activator.CreateInstance(info.PropertyType); IPropertyUIInterface newProperty = obj as IPropertyUIInterface; newProperty.PropertyFromString(valueList[index]); info.SetValue(this, newProperty, null); } } }
private void GetPropertyList(out string[] nameList, out string[] typeList, out string[] valueList) { PropertyInfo[] pInfoList = GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); List <string> nList = new List <string>(); List <string> tList = new List <string>(); List <string> vList = new List <string>(); foreach (PropertyInfo info in pInfoList) { if (info.CanRead && info.CanWrite) { object propertyObject = info.GetValue(this, null); if (propertyObject is IPropertyUIInterface) { IPropertyUIInterface obj = propertyObject as IPropertyUIInterface; nList.Add(info.Name); tList.Add(info.PropertyType.Name); vList.Add(obj.PropertyToString()); } } } nameList = nList.ToArray(); typeList = tList.ToArray(); valueList = vList.ToArray(); }