public static object getObject(FieldInfo fi, string src) { if (ReflecTools.equals(fi, typeof(string))) { return(StringTools.unescape(src)); } if (ReflecTools.equals(fi, typeof(int))) { return(int.Parse(src)); } if (ReflecTools.equals(fi, typeof(long))) { return(long.Parse(src)); } if (ReflecTools.equals(fi, typeof(bool))) { return(StringTools.toFlag(src)); } if (ReflecTools.equalsOrBase(fi, typeof(Serializable))) { object dest = fi.FieldType.InvokeMember(null, BindingFlags.CreateInstance, null, null, null); deserialize(dest, StringTools.decodeLines(src)); return(dest); } throw new Exception("そんなタイプ知りません:" + fi); }
public static string getString(FieldInfo fi, object src) { if (ReflecTools.equals(fi, typeof(string))) { return(StringTools.escape((string)src)); } if (ReflecTools.equals(fi, typeof(int))) { return("" + (int)src); } if (ReflecTools.equals(fi, typeof(long))) { return("" + (long)src); } if (ReflecTools.equals(fi, typeof(bool))) { return(StringTools.toString((bool)src)); } if (ReflecTools.equalsOrBase(fi, typeof(Serializable))) { return(StringTools.encodeLines(serialize(src))); } throw new Exception("そんなタイプ知りません:" + fi); }