Beispiel #1
0
        public void Insert <T>(SsdsEntity <T> entity) where T : class
        {
            SsdsEntitySerializer <T> serializer = new SsdsEntitySerializer <T>();
            string         payload = serializer.Serialize(entity);
            SsdsRestFacade facade  = this.CreateFacade();

            facade.Insert(payload);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a container on the given authority.
        /// </summary>
        /// <param name="name">The containers name.</param>
        /// <returns>The URI of the created container.</returns>
        public string CreateContainer(string name)
        {
            SsdsRestFacade facade    = this.CreateFacade();
            var            container = new XElement(Constants.ns + "Container",
                                                    new XElement(Constants.ns + "Id", name)
                                                    );

            return(facade.Insert(container.ToString()));
        }
Beispiel #3
0
        /// <summary>
        /// Creates an authority with given name.
        /// </summary>
        /// <param name="name">The authority name.</param>
        /// <returns>The URI of the created authority.</returns>
        public string CreateAuthority(string name)
        {
            SsdsRestFacade facade    = this.CreateFacade(true);
            var            authority = new XElement(Constants.ns + "Authority",
                                                    new XElement(Constants.ns + "Id", name)
                                                    );

            return(facade.Insert(authority.ToString()));
        }
Beispiel #4
0
        /// <summary>
        /// Updates the item on the container.
        /// </summary>
        /// <param name="entity">The item with the information to be updated.</param>
        public void Update <T>(SsdsEntity <T> entity, ConcurrencyPattern concurrencyPattern) where T : class, new()
        {
            Uri                      updateLocation = HttpRestUriTemplates.UpdateTemplate.BindByPosition(this.authority, this.container, entity.Id);
            SsdsRestFacade           facade         = this.CreateFacade(updateLocation);
            SsdsEntitySerializer <T> serializer     = new SsdsEntitySerializer <T>();
            string                   payload        = serializer.Serialize(entity);

            facade.Update(payload, concurrencyPattern, entity.Version.ToString());
        }
Beispiel #5
0
        private SsdsEntityBucket GetBucketFromExpression(Expression expression)
        {
            SsdsRestFacade        facade     = this.CreateFacade();
            SsdsExpressionVisitor translator = new SsdsExpressionVisitor();
            string criteria = translator.Translate(expression);
            var    response = facade.Get(criteria);

            var types = response.Elements().GroupBy(g => g.Name).Select(s => Type.GetType(s.Key.LocalName));

            return(new SsdsEntityBucket {
                Response = response, Types = types.ToArray()
            });
        }
Beispiel #6
0
        /// <summary>
        /// Retrieves multiple object from the container when the match with a criteria.
        /// </summary>
        /// <param name="expression">The expression of the criteria used to determine which will be the object.</param>
        /// <returns>IEnumerable of T populated with data from Ssds.</returns>
        public IEnumerable <SsdsEntity <T> > Query <T>(Expression <Func <SsdsEntity <T>, bool> > expression) where T : class
        {
            SsdsRestFacade facade = this.CreateFacade();

            //since we are querying by kind... add it in
            expression = AddKindToExpression <T>(expression);

            SsdsExpressionVisitor translator = new SsdsExpressionVisitor();
            string criteria = translator.Translate(expression);

            var response = facade.Get(criteria);

            if (response == null)
            {
                return(null);
            }

            SsdsEntitySerializer <T>      serializer = new SsdsEntitySerializer <T>();
            IEnumerable <SsdsEntity <T> > items      = serializer.DeserializeMany(response);

            return(items);
        }
Beispiel #7
0
        /// <summary>
        /// Creates a SsdsRestFacade used to send REST messages
        /// from and to the container/authority location.
        /// </summary>
        /// <returns>A new SsdsRestFacade instance.</returns>
        private SsdsRestFacade CreateFacade()
        {
            SsdsRestFacade facade = new SsdsRestFacade(this.connectionString.UserName, this.connectionString.Password, this.connectionString.ScopeUri);

            return(facade);
        }
Beispiel #8
0
        /// <summary>
        /// Returns a value indicating whether the container passed as parameter
        /// exists or not.
        /// </summary>
        /// <param name="name">The container name.</param>
        /// <returns>A value indicating whether the container exists.</returns>
        public bool ContainerExists(string name)
        {
            SsdsRestFacade facade = this.CreateFacade();

            return(facade.EntityExists(name));
        }
Beispiel #9
0
        /// <summary>
        /// Deletes a container on the given authority.
        /// </summary>
        /// <param name="name">The container's name.</param>
        public void DeleteContainer(string name)
        {
            SsdsRestFacade facade = this.CreateFacade();

            facade.Delete(name, ConcurrencyPattern.Always, null);
        }
Beispiel #10
0
        public string Insert(SsdsBlobEntity blob)
        {
            SsdsRestFacade facade = this.CreateFacade();

            return(facade.Insert(blob));
        }
Beispiel #11
0
        /// <summary>
        /// Create an instance of the SsdsRestFacade used to interact with the container.
        /// </summary>
        /// <param name="scope">The scope where the facade will be interacting with.</param>
        /// <returns>An instance of SsdsRestFacade.</returns>
        private SsdsRestFacade CreateFacade(Uri scope)
        {
            SsdsRestFacade facade = new SsdsRestFacade(this.userName, this.password, scope);

            return(facade);
        }
Beispiel #12
0
        public void Update(SsdsBlobEntity blob, ConcurrencyPattern concurrencyPattern)
        {
            SsdsRestFacade facade = this.CreateFacade();

            facade.Update(blob, concurrencyPattern);
        }
Beispiel #13
0
        private void Delete(string id, ConcurrencyPattern concurrencyPattern, string version)
        {
            SsdsRestFacade facade = this.CreateFacade();

            facade.Delete(id, concurrencyPattern, version);
        }
Beispiel #14
0
        public SsdsBlobEntity GetBlob(string entityId)
        {
            SsdsRestFacade facade = this.CreateFacade();

            return(facade.GetBlob(entityId));
        }