コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="languageCode"></param>
        /// <param name="fileRejection"></param>
        /// <returns></returns>
        public Boolean RejectTranslation(String languageCode, FileRejection fileRejection)
        {
            TargetLanguage targetLanguage = this.TargetLanguages.SingleOrDefault(p => p.LanguageCode == languageCode);

            if (targetLanguage == null)
            {
                throw new ArgumentException(string.Format("LanguageCode {0} is not one of the target languages for this file", languageCode), "languageCode");
            }

            if (this.Client == null)
            {
                throw new InvalidOperationException("The file does not have an APIClient to communicate with");
            }

            var file = this.Client.RejectFileTranslation(this.AssetID.ToString(), languageCode, fileRejection);

            return(file != null);
        }
コード例 #2
0
        /// <summary>
        /// Rejects the translation of a file
        /// </summary>
        /// <param name="assetID"></param>
        /// <param name="languageCode"></param>
        /// <param name="fileRejection"></param>
        public File RejectFileTranslation(String assetID, String languageCode, FileRejection fileRejection)
        {
            File result = null;

            if (String.IsNullOrEmpty(assetID))
            {
                if (assetID == null)
                {
                    throw new ArgumentNullException("assetID cannot be null");
                }
                throw new ArgumentException("asset ID cannot be empty");
            }

            if (String.IsNullOrEmpty(languageCode))
            {
                if (languageCode == null)
                {
                    throw new ArgumentNullException("languageCode cannot be null");
                }
                throw new ArgumentException("languageCode cannot be empty");
            }

            Uri uri = new Uri($"{this.EndPoint.AbsoluteUri}api/files/{assetID}/{languageCode}/reject");

            HttpWebRequest request = this.CreateRequestPOST(uri, fileRejection);

            using (HttpWebResponse response = request.GetResponseWithoutException() as HttpWebResponse)
            {
                if (response.StatusCode == HttpStatusCode.Accepted)
                {
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        XDocument document = XDocument.Load(reader);

                        result = new File(document.Element("File"), this);
                    }
                }
                else
                {
                    this.HandleError(response);
                }
            }

            return result;
        }
コード例 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="languageCode"></param>
        /// <param name="fileRejection"></param>
        /// <returns></returns>
        public Boolean RejectTranslation(String languageCode, FileRejection fileRejection)
        {
            TargetLanguage targetLanguage = this.TargetLanguages.SingleOrDefault(p => p.LanguageCode == languageCode);

            if (targetLanguage == null)
            {
                throw new ArgumentException(string.Format("LanguageCode {0} is not one of the target languages for this file", languageCode), "languageCode");
            }

            if (this.Client == null)
            {
                throw new InvalidOperationException("The file does not have an APIClient to communicate with");
            }

            var file = this.Client.RejectFileTranslation(this.AssetID.ToString(), languageCode, fileRejection);

            return file != null;
        }