コード例 #1
0
ファイル: DoerFactory.cs プロジェクト: uiopsczc/Test
        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);
        }
コード例 #2
0
        public static T GetSubDoer <T>(Doer parentDoer, string subDoerKey, string idOrRid) where T : Doer
        {
            if (IdUtil.IsId(idOrRid))             //id的情况
            {
                string id = idOrRid;
                var    ts = GetSubDoers <T>(parentDoer, subDoerKey, null, null);
                for (var i = 0; i < ts.Length; i++)
                {
                    var subDoer = ts[i];
                    if (subDoer.GetId().Equals(id))
                    {
                        return(subDoer);
                    }
                }

                return(null);
            }
            //rid的情况
            string rid = idOrRid;

            if (GetSubDoerDict_ToEdit(parentDoer, subDoerKey).ContainsKey(rid))
            {
                return(GetSubDoerDict_ToEdit(parentDoer, subDoerKey)[rid] as T);
            }
            return(null);
        }
コード例 #3
0
        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);
        }