Esempio n. 1
0
        public DataSource <T> DataSource <T>()
        {
            ClientSideTypeDescription typeDescription = TypeDescriptionsCache.GetDescription(typeof(T));

            typeDescription = Client.RegisterType(typeof(T), typeDescription);

            return(new DataSource <T>(Client, typeDescription));
        }
Esempio n. 2
0
 public void Commit()
 {
     foreach (var type in _types)
     {
         var description = TypeDescriptionsCache.GetDescription(type);
         _client.RegisterType(type, description);
     }
     _client.ExecuteTransaction(_itemsToPut, _conditions, _itemsToDelete);
 }
Esempio n. 3
0
        /// <summary>
        /// Declare collection with implicit schema (inferred from the type)
        /// If the collection name is not specified, the name of the type is used
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="collectionName"></param>
        public void DeclareCollection <T>(string collectionName = null)
        {
            collectionName ??= typeof(T).Name;

            var description = TypeDescriptionsCache.GetDescription(typeof(T));

            var schema = description;

            Client.DeclareCollection(collectionName, schema);

            lock (_collectionSchema)
            {
                _collectionSchema[collectionName] = schema;
            }
        }
Esempio n. 4
0
        /// <summary>
        ///     Conditional update. The condition is applied server-side on the previous version of the item
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="newValue"></param>
        /// <param name="test"></param>
        public void UpdateIf <T>(T newValue, Expression <Func <T, bool> > test)
        {
            var desc = TypeDescriptionsCache.GetDescription(typeof(T));

            var packed = Pack(newValue);

            _itemsToPut.Add(packed);

            var dataSource  = new DataSource <T>(_client, desc);
            var testAsQuery = dataSource.PredicateToQuery(test);

            _conditions.Add(testAsQuery);

            _types.Add(typeof(T));
        }
Esempio n. 5
0
        private CachedObject Pack <T>(T item)
        {
            var packed = CachedObject.Pack(item, TypeDescriptionsCache.GetDescription(typeof(T)));

            return(packed);
        }