Ejemplo n.º 1
0
        public static ClassifiedObject FromUser(long oid = 0, string name = null, long uid = 0, string userName = null, long userSesionID = 0, object tag = null)
        {
            if (null == name)
            {
                name = string.Empty;
            }

            if (null == userName)
            {
                userName = string.Empty;
            }

            var obj = new ClassifiedObject()
            {
                HasUserIdentity = true,
                OID             = oid,
                Name            = name,
                UID             = uid,
                UserName        = userName,
                UserSessionID   = userSesionID,
                Tag             = tag
            };

            return(obj);
        }
Ejemplo n.º 2
0
 public void RemoveWithUser(long oid = 0, string name = null, long uid = 0, string userName = null, long userSesionID = 0)
 {
     try
     {
         RemoveObject(ClassifiedObject.MakeKeyWithUser(oid, name, uid, userName, userSesionID));
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 3
0
 public void Remove(long oid = 0, string name = null)
 {
     try
     {
         RemoveObject(ClassifiedObject.MakeKey(oid, name));
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 4
0
        public static ClassifiedObject FromOID(long oid = 0, string name = null, object tag = null)
        {
            if (null == name)
            {
                name = string.Empty;
            }

            var obj = new ClassifiedObject()
            {
                OID  = oid,
                Name = name,
                Tag  = tag
            };

            return(obj);
        }
Ejemplo n.º 5
0
        public T Get <T>(long oid = 0, string name = null)
            where T : class, new()
        {
            try
            {
                var obj = GetObject(ClassifiedObject.MakeKey(oid, name));
                if (null == obj)
                {
                    return(null);
                }

                return(obj.GetValue <T>());
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        private ClassifiedObject GetObject(ClassifiedObject obj)
        {
            try
            {
                string           strKey = obj.ToString();
                ClassifiedObject ret;
                if (this.Objects.TryGetValue(strKey, out ret))
                {
                    return(ret);
                }

                return(null);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 7
0
        public Tuple <T, object> TagGetWithUser <T>(long oid = 0, string name = null, long uid = 0, string userName = null, long userSesionID = 0)
            where T : class, new()
        {
            try
            {
                var obj = GetObject(ClassifiedObject.MakeKeyWithUser(oid, name, uid, userName, userSesionID));
                if (null == obj)
                {
                    return(null);
                }

                return(Tuple.Create(obj.GetValue <T>(), obj.Tag));
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 8
0
        public string Add <T>(T val, long oid = 0, string name = null, object tag = null, ulong indexKey = 0ul)
        {
            try
            {
                var obj = ClassifiedObject.FromOID(oid, name, tag);
                obj.IndexKey = indexKey;
                obj.Value    = val;
                string strKey = obj.ToString();
                this.Objects.AddOrUpdate(strKey, obj, (k, v) => { return(obj); });
                if (0ul != indexKey)
                {
                    _indexObjects.AddOrUpdate(indexKey, obj, (k, v) => { return(obj); });
                }

                return(strKey);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 9
0
        private ClassifiedObject RemoveObject(string key)
        {
            try
            {
                ClassifiedObject obj = null;
                if (this.Objects.TryRemove(key, out obj))
                {
                    if (0ul != obj.IndexKey)
                    {
                        ulong ulIndexKey = obj.IndexKey;
                        _indexObjects.TryRemove(ulIndexKey, out obj);
                    }
                }

                return(obj);
            }
            catch
            {
                throw;
            }
        }