Ejemplo n.º 1
0
        /// <summary>
        /// Asynchronously retrieves a user's folder structure by ID
        /// </summary>
        /// <param name="folderID">ID of the folder to retrieve</param>
        /// <param name="retrieveOptions">Retrieve options</param>
        /// <param name="getFolderStructureCompleted">Callback method which will be executed after operation completes</param>
        /// <param name="userState">A user-defined object containing state information. 
        /// This object is passed to the <paramref name="getFolderStructureCompleted"/> delegate as a part of response when the operation is completed</param>
        /// <exception cref="ArgumentException">Thrown if <paramref name="getFolderStructureCompleted"/> is null</exception>
        public void GetFolderStructure(
            long folderID,
            RetrieveFolderStructureOptions retrieveOptions,
            OperationFinished<GetFolderStructureResponse> getFolderStructureCompleted,
            object userState)
        {
            ThrowIfParameterIsNull(getFolderStructureCompleted, "getFolderStructureCompleted");

            object[] state = new object[3];

            state[0] = getFolderStructureCompleted;
            state[1] = retrieveOptions;
            state[2] = userState;

            _service.get_account_treeCompleted += GetFolderStructureFinished;

            _service.get_account_treeAsync(_apiKey, _token, folderID, retrieveOptions.ToStringArray(), state);
        }
Ejemplo n.º 2
0
        public GetAccountTreeStatus GetFolderStructure(
            long folderID,
            RetrieveFolderStructureOptions retrieveOptions,
            out Folder folder)
        {
            folder = null;

            byte[] folderInfoXml;

            string result = _service.get_account_tree(_apiKey, _token, folderID, retrieveOptions.ToStringArray(), out folderInfoXml);
            GetAccountTreeStatus status = StatusMessageParser.ParseGetAccountTreeStatus(result);

            switch (status)
            {
                case GetAccountTreeStatus.Successful:
                    string folderInfo = null;

                    if (!retrieveOptions.Contains(RetrieveFolderStructureOptions.NoZip))
                    {
                        folderInfoXml = Unzip(folderInfoXml);
                    }

                    if (folderInfoXml != null)
                    {
                        folderInfo = Encoding.ASCII.GetString(folderInfoXml);
                    }

                    folder = ParseFolderStructureXmlMessage(folderInfo);
                    break;
            }

            return status;
        }