public Doer FindDoers(string idOrRid) { string id = IdUtil.RidToId(idOrRid); bool isId = IdUtil.IsId(idOrRid); if (idDict.TryGetValue(id, out var dict)) { if (dict.Count != 0) { foreach (var rid in this.idDict[id].Keys) { var dbase = idDict[id][rid]; if (isId) { return(dbase.GetDoer()); } if (rid.Equals(idOrRid)) { return(dbase.GetDoer()); } } } } return(null); }
public static T GetSubDoer <T>(Doer parentDoer, string subDoerKey, string idOrRid) where T : Doer { bool isId = IdUtil.IsId(idOrRid); string id = isId ? idOrRid : IdUtil.RidToId(idOrRid); var dict = GetSubDoerDict_ToEdit(parentDoer, subDoerKey); if (dict.ContainsKey(id) && !(dict[id] as ArrayList).IsNullOrEmpty()) { var arrayList = dict[id] as ArrayList; for (var i = 0; i < arrayList.Count; i++) { var subDoer = (T)arrayList[i]; if (isId) { return(subDoer); } if (subDoer.GetRid().Equals(idOrRid)) { return(subDoer); } } } return(null); }
public DBase(string idOrRid, Hashtable db = null, Hashtable dbTmp = null) { if (IdUtil.IsRid(idOrRid)) { string rid = idOrRid; this.rid = rid; this.id = IdUtil.RidToId(rid); } else { this.id = idOrRid; this.rid = IdUtil.NewRid(this.id); } this.db = db ?? new Hashtable(); this.dbTmp = dbTmp ?? new Hashtable(); }
// 创建逻辑对象 public Doer NewDoer(string idOrRid) { string id = IdUtil.RidToId(idOrRid); var doer = this._NewDoer(id); var dbase = this._NewDBase(idOrRid); doer.SetDBase(dbase); dbase.SetDoer(doer); doer.factory = this; string rid = dbase.GetRid(); var dbaseDict = this.idDict.GetOrAddDefault(id, () => new Dictionary <string, DBase>()); dbaseDict[rid] = dbase; doer.Init(); doer.PostInit(); doer.SetIsEnabled(true, false); return(doer); }
public static T RemoveSubDoer <T>(Doer parentDoer, string subDoerKey, string rid) where T : Doer { var id = IdUtil.RidToId(rid); var subDoers = GetSubDoers_ToEdit(parentDoer, subDoerKey, id); for (int i = subDoers.Count - 1; i >= 0; i--) { var curSubDoer = subDoers[i] as T; if (curSubDoer.GetRid().Equals(rid)) { curSubDoer.SetEnv(null); subDoers.RemoveAt(i); return(curSubDoer); } } return(null); }