Exemplo n.º 1
0
        /// <summary>
        /// Fetches User objects from in-memory cache or remote server or database.
        /// </summary>
        public static Dictionary <string, User> FetchById(SortedSet <string> values, funapi.LockType lock_type = funapi.LockType.kWriteLock)
        {
            // TODO(seunghyun): remove unnecessary casting, boxing and unboxing for SortedSet values.
            SortedSet <object> values2 = new SortedSet <object>();

            foreach (object v in values)
            {
                values2.Add(v);
            }
            Dictionary <object, funapi.Object> objects = funapi.Object.FetchByKey("User", "Id", values2, lock_type);

            Dictionary <string, User> objects2 = new Dictionary <string, User>();

            foreach (KeyValuePair <object, funapi.Object> v in objects)
            {
                User obj = null;
                if (v.Value != null)
                {
                    obj = (User)v.Value.GetWrapperObject(typeof(User));
                }
                objects2.Add((string)v.Key, obj);
            }

            return(objects2);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Fetches User object from in-memory cache or remote server or database.
 /// </summary>
 public static User FetchById(string value, funapi.LockType lock_type = funapi.LockType.kWriteLock)
 {
     funapi.Object obj = funapi.Object.FetchByKey("User", "Id", value, lock_type);
     if (obj == null)
     {
         return(null);
     }
     return((User)obj.GetWrapperObject(typeof(User)));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Fetches User object from in-memory cache or remote server or database.
 /// </summary>
 public static User Fetch(System.Guid object_id, funapi.LockType lock_type = funapi.LockType.kWriteLock)
 {
     funapi.Object obj = funapi.Object.FetchById("User", object_id, lock_type);
     if (obj == null)
     {
         return(null);
     }
     return((User)obj.GetWrapperObject(typeof(User)));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Fetches User object randomly from in-memory cache or remote server or database.
        /// </summary>
        public static List <User> FetchRandomly(ulong count, funapi.LockType lock_type = funapi.LockType.kWriteLock)
        {
            List <funapi.Object> objects  = funapi.Object.FetchRandomly("User", count, lock_type);
            List <User>          objects2 = new List <User>();

            foreach (funapi.Object v in objects)
            {
                User obj = (User)v.GetWrapperObject(typeof(User));
                objects2.Add(obj);
            }
            return(objects2);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Makes the object accessible in the current event.
        /// </summary>
        public bool Refresh(funapi.LockType lock_type)
        {
            if (IsFresh() && object_.LockType >= lock_type)
            {
                return(true);
            }

            funapi.Object obj = funapi.Object.FetchById("User", Id, lock_type);
            if (obj == null)
            {
                return(false);
            }

            object_ = obj;
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Fetches User objects from in-memory cache or remote server or database.
        /// </summary>
        public static Dictionary <System.Guid, User> Fetch(SortedSet <System.Guid> object_ids, funapi.LockType lock_type = funapi.LockType.kWriteLock)
        {
            Dictionary <System.Guid, funapi.Object> objects = new Dictionary <System.Guid, funapi.Object> ();

            funapi.Object.FetchById("User", object_ids, lock_type, objects);

            Dictionary <System.Guid, User> objects2 = new Dictionary <System.Guid, User>();

            foreach (KeyValuePair <System.Guid, funapi.Object> v in objects)
            {
                User obj = null;
                if (v.Value != null)
                {
                    obj = (User)v.Value.GetWrapperObject(typeof(User));
                }
                objects2.Add(v.Key, obj);
            }

            return(objects2);
        }