/// <summary> /// Reads service properties from a stream. /// </summary> /// <param name="inputStream">The stream from which to read the service properties.</param> /// <returns>The service properties stored in the stream.</returns> public static Task <FileServiceProperties> ReadServicePropertiesAsync(Stream inputStream, CancellationToken token) { return(Task.Run( () => { using (XmlReader reader = XmlReader.Create(inputStream)) { XDocument servicePropertyDocument = XDocument.Load(reader); return FileServiceProperties.FromServiceXml(servicePropertyDocument); } }, token )); }
/// <summary> /// Constructs a <c>ServiceProperties</c> object from an XML document received from the service. /// </summary> /// <param name="servicePropertiesDocument">The XML document.</param> /// <returns>A <c>ServiceProperties</c> object containing the properties in the XML document.</returns> internal static FileServiceProperties FromServiceXml(XDocument servicePropertiesDocument) { XElement servicePropertiesElement = servicePropertiesDocument.Element(ServiceProperties.StorageServicePropertiesName); FileServiceProperties properties = new FileServiceProperties { Cors = ServiceProperties.ReadCorsPropertiesFromXml(servicePropertiesElement.Element(ServiceProperties.CorsName)), HourMetrics = ServiceProperties.ReadMetricsPropertiesFromXml( servicePropertiesElement.Element(ServiceProperties.HourMetricsName)), MinuteMetrics = ServiceProperties.ReadMetricsPropertiesFromXml( servicePropertiesElement.Element(ServiceProperties.MinuteMetricsName)) }; return(properties); }