public static IPara GetPara(object obj, string field) { if (obj == null) { return(null); } FieldInfo f = GetField(obj, field); AbstractPara para = null; if (f != null) { string type = f.FieldType.Name; if (ParseUtility.IsInt64(type)) { para = new LongPara(field); } if (ParseUtility.IsInt32(type)) { para = new IntPara(field); } if (ParseUtility.IsSingle(type)) { para = new FloatPara(field); } if (ParseUtility.IsDouble(type)) { para = new DoublePara(field); } if (ParseUtility.IsString(type)) { para = new StringPara(field); } if (ParseUtility.IsBoolean(type)) { para = new BoolPara(field); } try { if (para != null) { para.SetValue(f.GetValue(obj)); } } catch (Exception e) { throw new GameConfigExpception(field + " is not a valid field.\n" + ExceptionUtil.GetExceptionContent(e)); } } return(para); }
public static bool ContainType(string type) { return(ParseUtility.IsBoolean(type) || ParseUtility.IsSingle(type) || ParseUtility.IsDouble(type) || ParseUtility.IsInt64(type) || ParseUtility.IsInt32(type) || ParseUtility.IsString(type)); }