Exemplo n.º 1
0
        /// <summary>
        /// Sets the value of a particular property or adds a new property if the specified property does not exist
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public bool SetDocumentProperty(string propertyName, string value)
        {
            //build URI to remove single property
            string strURI    = Product.BaseProductUri + "/slides/" + FileName + "/documentProperties/" + propertyName;
            string signedURI = Utils.Sign(strURI);

            //serialize the JSON request content
            DocumentProperty docProperty = new DocumentProperty();

            docProperty.Value = value;
            string strJSON = JsonConvert.SerializeObject(docProperty);

            Stream       responseStream = Utils.ProcessCommand(signedURI, "PUT", strJSON);
            StreamReader reader         = new StreamReader(responseStream);
            string       strResponse    = reader.ReadToEnd();
            //Parse the json string to JObject
            JObject pJSON = JObject.Parse(strResponse);

            DocumentPropertyResponse baseResponse = JsonConvert.DeserializeObject <DocumentPropertyResponse>(pJSON.ToString());

            if ((baseResponse.Code == "200" && baseResponse.Status == "OK") || (baseResponse.Code == "201" && baseResponse.Status == "Created"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the value of a particular property
        /// </summary>
        /// <param name="propertyName"></param>
        /// <returns>value of the specified property</returns>
        public DocumentProperty GetDocumentProperty(string propertyName)
        {
            //build URI to get single property
            string strURI    = Product.BaseProductUri + "/slides/" + FileName + "/presentation/documentProperties/" + propertyName;
            string signedURI = Utils.Sign(strURI);

            Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

            StreamReader reader  = new StreamReader(responseStream);
            string       strJSON = reader.ReadToEnd();

            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);

            //Deserializes the JSON to a object.
            DocumentPropertyResponse documentPropertyResponse = JsonConvert.DeserializeObject <DocumentPropertyResponse>(parsedJSON.ToString());

            return(documentPropertyResponse.DocumentProperty);
        }