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); }
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; } }
public void Remove(long oid = 0, string name = null) { try { RemoveObject(ClassifiedObject.MakeKey(oid, name)); } catch { throw; } }
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); }
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; } }
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; } }
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; } }
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; } }
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; } }