/// <summary> /// Gets all shapes in a slide from a 3rd party storage /// </summary> /// <param name="slideNumber"></param> /// <param name="storageType"></param> /// <param name="storageName">Name of the storage</param> /// <param name="folderName">In case of Amazon S3 storage the folder's path starts with Amazon S3 Bucket name.</param> /// <returns></returns> public List <Shape> GetShapes(int slideNumber, StorageType storageType, string storageName, string folderName) { //build URI to get shapes StringBuilder strURI = new StringBuilder(Product.BaseProductUri + "/slides/" + FileName + "/slides/" + slideNumber + "/shapes" + (string.IsNullOrEmpty(folderName) ? "" : "?folder=" + folderName)); switch (storageType) { case StorageType.AmazonS3: strURI.Append("&storage=" + storageName); break; } string signedURI = Utils.Sign(strURI.ToString()); 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. ShapesResponse shapesResponse = JsonConvert.DeserializeObject <ShapesResponse>(parsedJSON.ToString()); List <Shape> shapes = new List <Shape>(); foreach (ShapeURI shapeURI in shapesResponse.ShapeList.ShapesLinks) { StringBuilder uri = new StringBuilder(shapeURI.Uri.Href + (string.IsNullOrEmpty(folderName) ? "" : "?folder=" + folderName)); switch (storageType) { case StorageType.AmazonS3: uri.Append("&storage=" + storageName); break; } //Parse the json string to JObject JObject parsedShapeJSON = ProcessURI(uri.ToString()); //Deserializes the JSON to a object. ShapeResponse shapeResponse = JsonConvert.DeserializeObject <ShapeResponse>(parsedShapeJSON.ToString()); shapes.Add(shapeResponse.Shape); } return(shapes); }
/// <summary> /// Gets all shapes from the specified slide /// </summary> /// <param name="slideNumber"></param> /// <returns></returns> public List <Shape> GetShapes(int slideNumber) { try { //build URI to get shapes string strURI = Product.BaseProductUri + "/slides/" + FileName + "/slides/" + slideNumber + "/shapes"; 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. ShapesResponse shapesResponse = JsonConvert.DeserializeObject <ShapesResponse>(parsedJSON.ToString()); List <Shape> shapes = new List <Shape>(); foreach (ShapeURI shapeURI in shapesResponse.ShapeList.ShapesLinks) { //Parse the json string to JObject JObject parsedShapeJSON = ProcessURI(shapeURI.Uri.Href); //Deserializes the JSON to a object. ShapeResponse shapeResponse = JsonConvert.DeserializeObject <ShapeResponse>(parsedShapeJSON.ToString()); shapes.Add(shapeResponse.Shape); } return(shapes); } catch (Exception ex) { throw ex; } }