public override void DoAction(IEventArgs args) { object target = GetTarget(args); if (fields != null && values != null) { string[] fs = StringUtil.Split(fields, ","); string[] vs = StringUtil.Split(values, ","); if (fs.Length == vs.Length) { for (int i = 0; i < fs.Length; i++) { try { string fName = fs[i].Trim(); FieldInfo f = ReflectionCache.GetField(target, fName); string type = f.GetType().Name.ToLower(); IPara p = null; string[] ss = StringUtil.Split(vs[i].Trim(), "."); if (ss.Length == 2) { if (args.GetUnit(ss[0].Trim()) != null) { p = args.GetUnit(ss[0].Trim()).GetParameters().Get(ss[1].Trim()); } } else { if (ss.Length == 1) { p = args.GetDefault().GetParameters().Get(ss[0].Trim()); } } object v = null; if (p != null) { v = p.GetValue(); } if ("long".Equals(type)) { if (v == null) { v = long.Parse(vs[i].Trim()); } } else { if ("int".Equals(type)) { if (v == null) { v = int.Parse(vs[i].Trim()); } } else { if ("float".Equals(type)) { if (v == null) { v = float.Parse(vs[i].Trim()); } } else { if ("double".Equals(type)) { if (v == null) { v = double.Parse(vs[i].Trim()); } } else { if ("string".Equals(type)) { if (v == null) { v = vs[i].Trim().ToString(); } } else { if ("boolean".Equals(type)) { if (v == null) { v = bool.Parse(vs[i].Trim()); } } else { throw new GameConfigExpception(fName + "'s type '" + type + "' is not supported."); } } } } } } SetValue(target, f, v); System.Console.Out.WriteLine(target.GetType().FullName + "'s " + fName + " -> " + v); } catch (Exception e) { throw new GameConfigExpception("set " + fields + " to " + values + " failed at " + target.GetType().FullName + "\n" + ExceptionUtil.GetExceptionContent(e)); } } } } }