private PropertyInfo SetProperty(object obj, string line) { IniKeyAttribute keyAttr = ParseKeyAttribute(line); string propertyValue = ParsePropertyValue(line); PropertyInfo prop = null; if (propertyValue != null) { prop = type.GetProperty(MakeFirstLetterUpperCase(keyAttr.ElementName)); string propType = prop.PropertyType.Name; if (propType.Contains("Int")) { prop.SetValue(obj, Convert.ToInt16(propertyValue)); } if (propType.Equals("Double")) { prop.SetValue(obj, Convert.ToDouble(propertyValue)); } if (propType.Equals("String")) { prop.SetValue(obj, propertyValue); } IniKeyAttribute tempKeyAttr = (IniKeyAttribute)Attribute.GetCustomAttribute(prop, typeof(IniKeyAttribute)); tempKeyAttr = keyAttr; } return(prop); }
private IniKeyAttribute ParseKeyAttribute(string line) { string result = null; if (line.Contains("=")) { string[] tmp = line.Split('='); result = tmp[0]; IniKeyAttribute attr = new IniKeyAttribute(); attr.ElementName = result; return(attr); } return(null); }
private IniKeyAttribute ParseKeyAttribute(string line) { string result = null; if (line.Contains("=")) { string[] tmp = line.Split('='); result = tmp[0]; IniKeyAttribute attr = new IniKeyAttribute(); attr.ElementName = result; return attr; } return null; }