Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public static void Clear(this StorageValue value)
 {
     value.Context.Delete(value.BaseKey);
 }
Ejemplo n.º 4
0
 public static bool HasValue(this StorageValue value)
 {
     return(value.Context.Has(value.BaseKey));
 }