Exemple #1
0
        public static T Get <T>(this StorageValue value)
        {
            var bytes = value.Context.Get(value.BaseKey);

            if (typeof(IStorageCollection).IsAssignableFrom(typeof(T)))
            {
                var args = new object[] { bytes, value.Context };
                var obj  = (T)Activator.CreateInstance(typeof(T), args);
                return(obj);
            }
            else
            {
                return(Serialization.Unserialize <T>(bytes));
            }
        }
Exemple #2
0
        public static void Set <T>(this StorageValue value, T element)
        {
            byte[] bytes;
            if (typeof(IStorageCollection).IsAssignableFrom(typeof(T)))
            {
                var collection = (IStorageCollection)element;
                //bytes = MergeKey(map.BaseKey, key);
                bytes = collection.BaseKey;
            }
            else
            {
                bytes = Serialization.Serialize(element);
            }

            value.Context.Put(value.BaseKey, bytes);
        }
Exemple #3
0
 public static void Clear(this StorageValue value)
 {
     value.Context.Delete(value.BaseKey);
 }
Exemple #4
0
 public static bool HasValue(this StorageValue value)
 {
     return(value.Context.Has(value.BaseKey));
 }