public virtual void AddParaList(ParaList paras) { if (cache == null) { cache = new MyDictionary <string, MyDictionary <string, ParaList> >(); } if (StringUtil.IsNullOrEmpty(order) && StringUtil.IsNullOrEmpty(unique)) { if (this.list.Count < this.capacity) { this.list.Add(paras); foreach (string f in paras.GetFields()) { if (!cache.ContainsKey(f)) { cache[f] = new MyDictionary <string, ParaList>(); } IPara p = paras.Get(f); if (p != null && p.GetValue() != null) { cache[f][p.GetValue().ToString()] = paras; } else { throw new GameConfigExpception(paras + " has null element"); } } } } else { this.list.Add(paras); this.list = Select(this.list, this.order, this.capacity); } }
private string GetKey(ParaList paras) { if (!StringUtil.IsNullOrEmpty(unique)) { if (uniKeys == null) { uniKeys = new HashSet <string>(); foreach (string uni in StringUtil.Split(unique, ",")) { uniKeys.Add(uni.Trim()); } } IList <string> list = new List <string>(); foreach (string uni_1 in uniKeys) { IPara para = paras.Get(uni_1); if (para != null) { list.Add(para.GetValue().ToString()); } } string key = StringUtil.GetStringFromStrings(list, "-"); if (!StringUtil.IsNullOrEmpty(key)) { return(key); } } return(null); }
public override void SetValue(string op, IPara v) { if (OP_ADD.Equals(op)) { elapseTime = elapseTime + (int)v.GetValue(); } else { if (OP_MINUS.Equals(op)) { elapseTime = elapseTime - (int)v.GetValue(); } else { if (OP_ASSIGN.Equals(op)) { if (v is IntPara) { totalTime = (int)v.GetValue(); elapseTime = 0; } else { if (v is com.wd.free.para.TimeElapsePara) { com.wd.free.para.TimeElapsePara tep = (com.wd.free.para.TimeElapsePara)v; totalTime = tep.totalTime; elapseTime = tep.elapseTime; } } } } } }
public override bool Meet(string con, IPara v) { if (v == null) { return(false); } if ("==".Equals(con)) { if (v is IntPara) { return(map.Count == (int)v.GetValue()); } } else { if (CON_NOT_EQUAL.Equals(con)) { if (v is StringPara) { return(map.ContainsKey((string)v.GetValue())); } } } return(false); }
public override bool Meet(string con, IPara v) { if (v == null) { return(false); } if ("==".Equals(con)) { if (value != null) { return(value.Equals(v.GetValue())); } } else { if (CON_NOT_EQUAL.Equals(con)) { if (value != null) { return(!value.Equals(v.GetValue())); } } } return(false); }
public override void SetValue(string op, IPara v) { if (v == null) { return; } if ("=".Equals(op)) { value = v.GetValue(); } }
public FieldPara(object obj, string fieldName, FieldInfo field) : base() { this.obj = obj; this.field = field; this.name = fieldName; this.para = ReflectionCache.GetPara(obj, fieldName); if (para == null) { throw new GameConfigExpception(fieldName + " can not be set/get at " + obj.GetType().FullName); } }
public virtual void TempUse(IPara para) { if (temp == null) { temp = new MyDictionary <string, Stack <IPara> >(); } if (!temp.ContainsKey(para.GetName())) { temp[para.GetName()] = new Stack <IPara>(); } temp[para.GetName()].Push(paras[para.GetName()]); this.paras[para.GetName()] = para; }
public virtual void Resume(string key) { IPara old = temp[key].Pop(); if (old != null) { this.paras[key] = old; } else { this.paras.Remove(key); } }
public virtual T BorrowObject() { if (intList.IsEmpty()) { IPara p = (IPara)t.Copy(); if (p is AbstractPara) { ((AbstractPara)p).SetTemp(true); } intList.Push((T)p); } return(intList.Pop()); }
public virtual IPara GetPara(IEventArgs args) { IPara para = ParaUtil.GetPara(type); if (para != null) { para = (IPara)para.Copy(); para.SetName(name); if (value == null) { value = string.Empty; } if (para is StringPara) { ((StringPara)para).SetValue(FreeUtil.ReplaceVar(value, args)); } else if (para is BoolPara) { ((BoolPara)para).SetValue(FreeUtil.ReplaceBool(value, args)); } else { double v = FreeUtil.ReplaceDouble(value, args); if (para is IntPara) { ((IntPara)para).SetValue((int)v); } else { if (para is FloatPara) { ((FloatPara)para).SetValue((float)v); } else { if (para is DoublePara) { ((DoublePara)para).SetValue(v); } } } } para.SetPublic(isPublic); para.SetName(FreeUtil.ReplaceVar(para.GetName(), args)); } return(para); }
public override void SetValue(string op, IPara v) { try { para.SetValue(op, v); if (op.Equals(OP_ASSIGN)) { field.SetValue(obj, para.GetValue()); } } catch (Exception e) { throw new GameConfigExpception("set value failed.\n" + ExceptionUtil.GetExceptionContent(e)); } }
public override void SetValue(string op, IPara v) { if (v == null) { return; } double v1 = GetDouble(value); double v2 = GetDouble(v.GetValue()); switch (op) { case OP_ASSIGN: { value = v2; break; } case OP_ADD: { value = v1 + v2; break; } case OP_MINUS: { value = v1 - v2; break; } case OP_MULTI: { value = v1 * v2; break; } case OP_DIVIDE: { value = v1 / v2; break; } case OP_MOD: { value = v1 % v2; break; } } }
public virtual IPara BorrowObject() { if (/*intList.IsEmpty()*/ 0 == this.Count) { IPara p = (IPara)this.obj.Copy(); if (p is AbstractPara) { ((AbstractPara)p).SetTemp(true); } intList.Push(p); this.Count++; } object temp = intList.Pop(); this.Count--; return(temp as IPara); }
public override bool HasPara(IPara para) { bool has = this.paras.ContainsKey(para.GetName()); if (!has) { for (int i = 0; i < fieldList.Count; i++) { IFields f = fieldList[i]; if (f.HasField(para.GetName())) { return(true); } } } return(has); }
public override bool HasPara(string para) { IPara v = null; bool has = this.paras.TryGetValue(para, out v); if (!has) { for (int i = 0, maxi = fieldList.Count; i < maxi; i++) { IFields f = fieldList[i]; if (f.HasField(para)) { return(true); } } } return(has); }
public virtual ParaList GetParaList(string field, string value, IEventArgs args) { if (StringUtil.IsNullOrEmpty(order) && StringUtil.IsNullOrEmpty(unique)) { if (cache == null) { cache = new MyDictionary <string, MyDictionary <string, ParaList> >(); } if (cache.ContainsKey(field) && cache[field].ContainsKey(value)) { return(cache[field][value]); } } else { foreach (ParaList pl in list) { IPara para = pl.Get(field); if (para != null) { try { IPara temp = para.Initial("==", value); bool m = para.Meet("==", temp); temp.Recycle(); if (m) { return(pl); } } catch (Exception) { } UnitPara up = UnitPara.ParseOne(value); IPara vPara = up.GetPara(args); if (vPara != null && para.Meet("==", vPara)) { return(pl); } } } } return(null); }
public override void SetValue(string op, IPara v) { long v1 = GetLong(value); long v2 = GetLong(v.GetValue()); switch (op) { case OP_ASSIGN: { value = v2; break; } case OP_ADD: { value = v1 + v2; break; } case OP_MINUS: { value = v1 - v2; break; } case OP_MULTI: { value = v1 * v2; break; } case OP_DIVIDE: { value = v1 / v2; break; } case OP_MOD: { value = v1 % v2; break; } } }
public override bool Meet(string con, IPara v) { if (v == null) { return(false); } double v1 = GetDouble(value); double v2 = GetDouble(v.GetValue()); switch (con) { case CON_EQUAL: { return(v1 == v2); } case CON_NOT_EQUAL: { return(v1 != v2); } case CON_GE: { return(v1 >= v2); } case CON_LE: { return(v1 <= v2); } case CON_GREATER: { return(v1 > v2); } case CON_LESS: { return(v1 < v2); } } return(false); }
public override bool Meet(string con, IPara v) { if (v is IntPara || v is UpdatePara) { int ev = ((int)GetValue()); int cv = ((int)v.GetValue()); if ("==".Equals(con)) { return(ev == cv); } else { if (">".Equals(con)) { return(ev > cv); } else { if ("<".Equals(con)) { return(ev < cv); } else { if (">=".Equals(con)) { return(ev >= cv); } else { if ("<=".Equals(con)) { return(ev <= cv); } } } } } } return(false); }
public override bool Meet(string con, IPara v) { int v1 = list.Count; int v2 = (int)v.GetValue(); switch (con) { case CON_EQUAL: { return(v1 == v2); } case CON_NOT_EQUAL: { return(v1 != v2); } case CON_GE: { return(v1 >= v2); } case CON_LE: { return(v1 <= v2); } case CON_GREATER: { return(v1 > v2); } case CON_LESS: { return(v1 < v2); } } return(false); }
public override bool Meet(string con, IPara v) { long v1 = GetLong(value); long v2 = GetLong(v.GetValue()); switch (con) { case CON_EQUAL: { return(v1 == v2); } case CON_NOT_EQUAL: { return(v1 != v2); } case CON_GE: { return(v1 >= v2); } case CON_LE: { return(v1 <= v2); } case CON_GREATER: { return(v1 > v2); } case CON_LESS: { return(v1 < v2); } } return(false); }
public override IPara Get(string name) { IPara para = null; paras.TryGetValue(name, out para); if (para == null) { for (int i = 0; i < fieldList.Count; i++) { IFields f = fieldList[i]; if (f.HasField(name)) { para = f.Get(name); if (para != null) { return(para); } } } } return(para); }
public override void SetValue(string op, IPara v) { if (v == null) { return; } string v1 = value.ToString(); string v2 = v.GetValue().ToString(); switch (op) { case OP_ASSIGN: { value = v2; break; } case OP_ADD: { value = v1 + v2; break; } } }
public override bool Meet(string con, IPara v) { return(para.Meet(con, v)); }
public static bool IsBasicPara(IPara p) { return(p is IntPara || p is StringPara || p is BoolPara || p is LongPara || p is FloatPara || p is DoublePara); }
public virtual void RemovePara(IPara para) { this.paras.Remove(para.GetName()); }
public override bool HasPara(IPara para) { string paraName = para.GetName(); return(HasPara(paraName)); }
public virtual bool HasPara(IPara para) { return(this.paras.ContainsKey(para.GetName())); }
public virtual void AddPara(IPara para) { this.paras[para.GetName()] = para; }