public static async Task <WsItemsReaderEngine> Create(WsApiClient apiClient, HttpResponseMessage responseMessage, WsFolderPath folderPath, bool useCreatedFileResolver)
        {
            WsItemsReaderEngine engine = new WsItemsReaderEngine(apiClient, responseMessage, folderPath, useCreatedFileResolver);
            XmlDocument         xml    = new XmlDocument();

            xml.Load(await engine._responseMessage.Content.ReadAsStreamAsync());
            engine._xmlReader = new XmlNodeReader(xml.DocumentElement);

            if (engine._xmlReader.Read() && engine._xmlReader.Name == ROOT_ELEMENT_NAME && engine._xmlReader.Read() && engine._xmlReader.Name == "status")
            {
                engine.Status = engine._xmlReader.ReadElementContentAsString();
                if (engine.Status != ResultStatus.OK)
                {
                    if (engine._xmlReader.Name == "code")
                    {
                        engine.ErrorCode = engine._xmlReader.ReadElementContentAsString();
                    }
                    engine.Dispose();
                }
            }
            else
            {
                engine.Status = "Xml format error.";
                engine.Dispose();
            }
            return(engine);
        }
 public void Dispose()
 {
     _disposed        = true;
     _getItemsInvoked = true;
     _xmlReader?.Dispose();
     _xmlReader = null;
     _responseMessage?.Dispose();
     _responseMessage = null;
     _childEngine?.Dispose();
     _childEngine = null;
 }
示例#3
0
 public void Dispose()
 {
     _readerEngine.Dispose();
 }