コード例 #1
0
        /// <summary>
        /// Constructor from XML
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        public Product(XElement element, IContentAPI client)
            : this()
        {
            this.Client = client;

            this.DueDate = element.GetChildValueAsDateTime("DueDate");

            this.Title = element.GetChildValue("Title");
            this.PrimaryCategory = element.GetChildValueAsInt32("PrimaryCategory");
            this.TopLevelCategory = element.GetChildValueAsInt32("TopLevelCategory");
            this.CategoryPath = element.GetChildValue("CategoryPath");

            XElement description = element.Element("Description");
            if (description != null)
            {
                this.Description = new ProductDescription(description);
            }

            this.AssetID = element.GetChildValueAsInt32("AssetID");
            this.ProjectURL = element.GetChildValue("ProjectURL");
            this.ProjectID = element.GetChildValueAsInt32("ProjectID");

            if (element.Element("SourceLanguage") != null)
            {
                this.SourceLanguage = new SourceLanguage(element.Element(XName.Get("SourceLanguage")));
            }

            this.SKUs = SKU.CreateEnumerable(element.Element("SKUs")).ToList<SKU>();

            XElement targetLanguages = element.Element(XName.Get("TargetLanguages"));
            if (targetLanguages != null)
            {
                this.TargetLanguages = TargetLanguage.CreateEnumerable(targetLanguages).ToArray<TargetLanguage>();
            }
        }
コード例 #2
0
        /// <summary>
        /// Constructor from XML
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        public Project(XElement element, IContentAPI client)
            : this()
        {
            this.Client = client;

            this.UpdateFromXElement(element);
        }
コード例 #3
0
        /// <summary>
        /// Create a File instance from an XML string
        /// </summary>
        /// <param name="element">A File element</param>
        public File(XElement element, IContentAPI client)
            : this()
        {
            this.Client = client;

            this.UpdateFromXElement(element);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        public QuoteAuthorization(XElement element, IContentAPI client)
        {
            this.Status     = element.GetChildValue("Status");
            this.PaymentURL = element.GetChildValue("PaymentURL");
            this.QuoteURL   = element.GetChildValue("QuoteURL");

            this.Projects = Project.CreateEnumerable(element.Element("Projects"), client).ToArray();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        public QuoteAuthorization(XElement element, IContentAPI client)
        {
            this.Status = element.GetChildValue("Status");
            this.PaymentURL = element.GetChildValue("PaymentURL");
            this.QuoteURL = element.GetChildValue("QuoteURL");

            this.Projects = Project.CreateEnumerable(element.Element("Projects"), client).ToArray();
        }
コード例 #6
0
        public void AddFileDocX()
        {
            IContentAPI servicePortal = ConstructServiceClient();

            File file = servicePortal.AddFile("en-us", supportFilesPath + "Use live layout and alignment guides.docx");

            Assert.IsNotNull(file);
            Assert.IsTrue(file.AssetID > 0);
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        internal static IEnumerable <Quote> CreateEnumerable(XElement element, IContentAPI client)
        {
            List <Quote> result = new List <Quote>();

            foreach (XElement quote in element.Elements("Quote"))
            {
                result.Add(new Quote(quote, client));
            }

            return(result);
        }
コード例 #8
0
        /// <summary>
        /// Create an Enumerable of Project from XML
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        internal static IEnumerable <Project> CreateEnumerable(XElement element, IContentAPI client)
        {
            List <Project> result = new List <Project>();

            foreach (XElement project in element.Elements("Project"))
            {
                result.Add(new Project(project, client));
            }

            return(result);
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        internal static IEnumerable <Service> CreateEnumerable(XElement element, IContentAPI client)
        {
            List <Service> result = new List <Service>();

            foreach (XElement service in element.Elements("Service"))
            {
                result.Add(new Service(service, client));
            }

            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        internal void Initialize(IContentAPI client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client", "Client cannot be null");
            }

            if (this.Currency == null)
            {
                this.Currency = client.DefaultCurrency;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="service"></param>
        internal void Initialize(IContentAPI client, Service service)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client", "Client cannot be null");
            }

            if (service == null)
            {
                throw new ArgumentNullException("service", "Service cannot be null");
            }

            if (this.Currency == null)
            {
                this.Currency = client.DefaultCurrency;
            }

            this.ServiceID = service.ServiceID;

            if (this.TargetLanguages == null)
            {
                this.TargetLanguages = service.TargetLanguages.Select(p => new TargetLanguage(p));
            }

            if (!service.SourceLanguages.Contains(this.SourceLanguage.LanguageCode))
            {
                throw new ArgumentOutOfRangeException("sourceLanguage", this.SourceLanguage.LanguageCode, "Source language must be in the Service's list of source languages");
            }

            if (this.TargetLanguages == null)
            {
                throw new ArgumentNullException("targetLanguages", "Target languages cannot be null");
            }

            if (this.TargetLanguages.Count() == 0)
            {
                throw new ArgumentOutOfRangeException("targetLanguages", "Must include at least one target language");
            }

            foreach (TargetLanguage targetLanguage in this.TargetLanguages)
            {
                if (!service.TargetLanguages.Contains(targetLanguage.LanguageCode))
                {
                    throw new ArgumentOutOfRangeException("targetLanguages", targetLanguage.LanguageCode, "Target lanauges must be in the Service's list of target languages");
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// Create a collection of Files.
        /// </summary>
        /// <param name="parentElement">A parent element to one or more child File elements</param>
        /// <returns>A collection of Files</returns>
        internal static IEnumerable <File> CreateEnumerable(XElement parentElement, IContentAPI client)
        {
            List <File> fileList = new List <File>();

            if (parentElement != null)
            {
                var elements = from el in parentElement.Elements() where (el.Name == "File" || el.Name == "ReferenceFile") select el;

                foreach (XElement file in elements)
                {
                    File childFile = new File(file, client);
                    fileList.Add(childFile);
                }
            }

            IEnumerable <File> files = fileList.ToArray <File>();

            return(files);
        }
コード例 #13
0
        /// <summary>
        /// Constructor from XML
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        internal Estimate(XElement element, IContentAPI client)
            : this()
        {
            this.Client = client;

            if (element != null)
            {
                XElement service = element.Element("Service");

                int serviceID = service.GetChildValueAsInt32("ServiceID");

                if (this.Client != null)
                {
                    this.Service = this.Client.GetService(serviceID);
                }

                this.Currency = element.GetChildValue("Currency");

                this.TotalCost = element.GetChildValueAsDecimal("TotalCost");
            }
        }
コード例 #14
0
        /// <summary>
        /// Constructor from XML
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        internal Estimate(XElement element, IContentAPI client)
            : this()
        {
            this.Client = client;

            if (element != null)
            {
                XElement service = element.Element("Service");

                int serviceID = service.GetChildValueAsInt32("ServiceID");

                if (this.Client != null)
                {
                    this.Service = this.Client.GetService(serviceID);
                }

                this.Currency = element.GetChildValue("Currency");

                this.TotalCost = element.GetChildValueAsDecimal("TotalCost");
            }
        }
コード例 #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        internal Service(XElement element, IContentAPI client)
            : this()
        {
            this.Client = client;

            if (element != null)
            {
                this.ServiceID = element.GetChildValueAsInt32("ServiceID");

                this.Name = element.GetChildValue("Name");

                this.Description = element.GetChildValue("Description");

                this.PriceDescription = element.GetChildValue("PriceDescription");

                this.ValidInputs = new ValidInputs(element.Element("ValidInputs"));

                XElement sourceLanguages = element.Element("SourceLanguages");

                if (sourceLanguages != null)
                {
                    foreach (XElement sourceLanguage in sourceLanguages.Descendants("LanguageCode"))
                    {
                        this.SourceLanguagesList.Add(sourceLanguage.Value);
                    }
                }

                XElement targetLanguages = element.Element("TargetLanguages");

                if (targetLanguages != null)
                {
                    foreach (XElement targetLanguage in targetLanguages.Descendants("LanguageCode"))
                    {
                        this.TargetLanguagesList.Add(targetLanguage.Value);
                    }
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        internal Service(XElement element, IContentAPI client)
            : this()
        {
            this.Client = client;

            if (element != null)
            {
                this.ServiceID = element.GetChildValueAsInt32("ServiceID");

                this.Name = element.GetChildValue("Name");

                this.Description = element.GetChildValue("Description");

                this.PriceDescription = element.GetChildValue("PriceDescription");

                this.ValidInputs = new ValidInputs(element.Element("ValidInputs"));

                XElement sourceLanguages = element.Element("SourceLanguages");

                if (sourceLanguages != null)
                {
                    foreach (XElement sourceLanguage in sourceLanguages.Descendants("LanguageCode"))
                    {
                        this.SourceLanguagesList.Add(sourceLanguage.Value);
                    }
                }

                XElement targetLanguages = element.Element("TargetLanguages");

                if (targetLanguages != null)
                {
                    foreach (XElement targetLanguage in targetLanguages.Descendants("LanguageCode"))
                    {
                        this.TargetLanguagesList.Add(targetLanguage.Value);
                    }
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// Constructor from XML
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        public Product(XElement element, IContentAPI client)
            : this()
        {
            this.Client = client;

            this.DueDate = element.GetChildValueAsDateTime("DueDate");

            this.Title            = element.GetChildValue("Title");
            this.PrimaryCategory  = element.GetChildValueAsInt32("PrimaryCategory");
            this.TopLevelCategory = element.GetChildValueAsInt32("TopLevelCategory");
            this.CategoryPath     = element.GetChildValue("CategoryPath");

            XElement description = element.Element("Description");

            if (description != null)
            {
                this.Description = new ProductDescription(description);
            }

            this.AssetID    = element.GetChildValueAsInt32("AssetID");
            this.ProjectURL = element.GetChildValue("ProjectURL");
            this.ProjectID  = element.GetChildValueAsInt32("ProjectID");

            if (element.Element("SourceLanguage") != null)
            {
                this.SourceLanguage = new SourceLanguage(element.Element(XName.Get("SourceLanguage")));
            }

            this.SKUs = SKU.CreateEnumerable(element.Element("SKUs")).ToList <SKU>();

            XElement targetLanguages = element.Element(XName.Get("TargetLanguages"));

            if (targetLanguages != null)
            {
                this.TargetLanguages = TargetLanguage.CreateEnumerable(targetLanguages).ToArray <TargetLanguage>();
            }
        }
コード例 #18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        internal static IEnumerable<Service> CreateEnumerable(XElement element, IContentAPI client)
        {
            List<Service> result = new List<Service>();

            foreach (XElement service in element.Elements("Service"))
            {
                result.Add(new Service(service, client));
            }

            return result;
        }
コード例 #19
0
        /// <summary>
        /// Create an Enumerable list of Product from XML
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        internal static IEnumerable<Product> CreateEnumerable(XElement element, IContentAPI client)
        {
            List<Product> result = new List<Product>();

            foreach (XElement product in element.Elements("Product"))
            {
                result.Add(new Product(product, client));
            }

            return result;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="client"></param>
        internal void Initialize(IContentAPI client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client", "Client cannot be null");
            }

            if (this.Currency == null)
            {
                this.Currency = client.DefaultCurrency;
            }
        }
コード例 #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        public Quote(XElement element, IContentAPI client)
        {
            this.Client = client;

            this.UpdateFromXElement(element);
        }
コード例 #22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        public Quote(XElement element, IContentAPI client)
        {
            this.Client = client;

            this.UpdateFromXElement(element);
        }
コード例 #23
0
        /// <summary>
        /// Create a collection of Files.
        /// </summary>
        /// <param name="parentElement">A parent element to one or more child File elements</param>
        /// <returns>A collection of Files</returns>
        internal static IEnumerable<File> CreateEnumerable(XElement parentElement, IContentAPI client)
        {
            List<File> fileList = new List<File>();

            if (parentElement != null)
            {
                var elements = from el in parentElement.Elements() where (el.Name == "File" || el.Name == "ReferenceFile") select el;

                foreach (XElement file in elements)
                {
                    File childFile = new File(file, client);
                    fileList.Add(childFile);
                }
            }

            IEnumerable<File> files = fileList.ToArray<File>();

            return files;
        }
コード例 #24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        internal static IEnumerable<Quote> CreateEnumerable(XElement element, IContentAPI client)
        {
            List<Quote> result = new List<Quote>();

            foreach (XElement quote in element.Elements("Quote"))
            {
                result.Add(new Quote(quote, client));
            }

            return result;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="client"></param>
        /// <param name="service"></param>
        internal void Initialize(IContentAPI client, Service service)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client", "Client cannot be null");
            }

            if (service == null)
            {
                throw new ArgumentNullException("service", "Service cannot be null");
            }

            if (this.Currency == null)
            {
                this.Currency = client.DefaultCurrency;
            }

            this.ServiceID = service.ServiceID;

            if (this.TargetLanguages == null)
            {
                this.TargetLanguages = service.TargetLanguages.Select(p => new TargetLanguage(p));
            }

            if (!service.SourceLanguages.Contains(this.SourceLanguage.LanguageCode))
            {
                throw new ArgumentOutOfRangeException("sourceLanguage", this.SourceLanguage.LanguageCode, "Source language must be in the Service's list of source languages");
            }

            if (this.TargetLanguages == null)
            {
                throw new ArgumentNullException("targetLanguages", "Target languages cannot be null");
            }

            if (this.TargetLanguages.Count() == 0)
            {
                throw new ArgumentOutOfRangeException("targetLanguages", "Must include at least one target language");
            }

            foreach (TargetLanguage targetLanguage in this.TargetLanguages)
            {
                if (!service.TargetLanguages.Contains(targetLanguage.LanguageCode))
                {
                    throw new ArgumentOutOfRangeException("targetLanguages", targetLanguage.LanguageCode, "Target lanauges must be in the Service's list of target languages");
                }
            }
        }