本文整理汇总了C#中System.Xml.Linq.XElement.GetChildValue方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.GetChildValue方法的具体用法?C# XElement.GetChildValue怎么用?C# XElement.GetChildValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XElement
的用法示例。
在下文中一共展示了XElement.GetChildValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Product
/// <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: AccountInformation
/// <summary>
/// Create an AccountInformation instance from an XML string
/// </summary>
/// <param name="element">An Account element</param>
internal AccountInformation(XElement element)
: this()
{
if (element != null)
{
this.Email = element.GetChildValue("Email");
this.Currency = element.GetChildValue("Currency");
this.TotalSpent = element.GetChildValueAsDecimal("TotalSpent");
this.TranslationCredit = element.GetChildValueAsInt32("TranslationCredit");
this.TranslationCreditUsed = element.GetChildValueAsInt32("TranslationCreditUsed");
this.PrepaidCredit = element.GetChildValueAsDecimal("PrepaidCredit");
this.ProductCount = element.GetChildValueAsInt32("ProductCount");
XElement targetLanguagesElement = element.Element("TargetLanguages");
if (targetLanguagesElement != null)
{
List<TargetLanguage> targets = new List<TargetLanguage>();
foreach (XElement targetLanguageElement in targetLanguagesElement.Elements("TargetLanguage"))
{
TargetLanguage targetLanguage = new TargetLanguage(targetLanguageElement);
targets.Add(targetLanguage);
}
this.TargetLanguages = targets;
}
}
}
示例3: ProductTranslation
/// <summary>
///
/// </summary>
/// <param name="element"></param>
public ProductTranslation(XElement element)
: this()
{
// Source SKUs
XElement skus = element.Element("SKUs");
if (skus != null)
{
this.SourceSKUs = SKU.CreateEnumerable(skus).ToArray<SKU>();
}
this.AssetID = element.GetChildValueAsInt32("AssetID");
this.SourceTitle = element.GetChildValue("SourceTitle");
this.Service = element.GetChildValueAsInt32("Service");
this.Language = element.GetChildValue("Language");
//Translated Fields
XElement translatedFields = element.Element("TranslatedFields");
if (translatedFields != null)
{
this.Title = translatedFields.GetChildValue("Title");
this.PrimaryCategory = translatedFields.GetChildValueAsInt32("PrimaryCategory");
XElement description = translatedFields.Element("Description");
if (description != null)
{
this.Description = new ProductDescription(description);
}
skus = translatedFields.Element("SKUs");
if (skus != null)
{
this.SKUs = SKU.CreateEnumerable(skus).ToArray<SKU>();
}
}
}
示例4: Error
/// <summary>
/// Create an Error instance from an XML element
/// </summary>
/// <param name="statusCode">The status code from the HTTP web response</param>
/// <param name="errorElement">An XML Error element</param>
public Error(HttpStatusCode statusCode, XElement errorElement)
{
/* The error element should have a structure similar to the one shown here:
<Error>
<ReasonCode>403</ReasonCode>
<SimpleMessage>Already exists.</SimpleMessage>
<DetailedMessage>A user with this email address already exists.</DetailedMessage>
</Error>
*/
this.HttpStatusCode = statusCode;
if (errorElement != null)
{
this.ReasonCode = errorElement.GetChildValueAsInt32("ReasonCode");
this.SimpleMessage = errorElement.GetChildValue("SimpleMessage");
this.DetailedMessage = errorElement.GetChildValue("DetailedMessage");
if (string.IsNullOrEmpty(this.SimpleMessage) && string.IsNullOrEmpty(this.DetailedMessage))
{
this.SimpleMessage = errorElement.Value;
}
}
else
{
this.SimpleMessage = this.HttpStatusCode.ToString();
}
}
示例5: ProjectNotification
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="client"></param>
public ProjectNotification(XElement element, ContentAPI client)
: this()
{
if (element != null)
{
this.ProjectID = element.GetChildValueAsInt32("ProjectID");
this.Status = element.GetChildValue("Status");
this.URL = new Uri(element.GetChildValue("URL"));
this.CreationDate = element.GetChildValueAsDateTime("CreationDate");
this.DueDate = element.GetChildValueAsDateTime("DueDate");
this.CompletionDate = element.GetChildValueAsDateTime("CompletionDate");
XElement errors = element.Element("Errors");
if (errors != null)
{
foreach (XElement error in errors.Elements("Error"))
{
this.ErrorsList.Add(error.Value);
}
}
XElement sourceLanguage = element.Element("SourceLanguage");
if (sourceLanguage != null)
{
this.SourceLanguage = sourceLanguage.GetChildValue("LanguageCode");
}
XElement targetLanguages = element.Element("TargetLanguages");
if (targetLanguages != null)
{
foreach (XElement targetLanguage in targetLanguages.Descendants("LanguageCode"))
{
this.TargetLanguagesList.Add(targetLanguage.Value);
}
}
XElement products = element.Element("Products");
if (products != null)
{
this.Products = Product.CreateEnumerable(products, client);
}
XElement files = element.Element("Files");
if (files != null)
{
this.Files = File.CreateEnumerable(files, client);
}
}
}
示例6: Locale
/// <summary>
/// Constructor from XML
/// </summary>
/// <param name="element"></param>
internal Locale(XElement element)
{
if (element != null)
{
this.Name = element.GetChildValue("Name");
this.Code = element.GetChildValue("Code");
}
}
示例7: QuoteAuthorization
/// <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();
}
示例8: AddCreditBalance
/// <summary>
/// Creates an AddCreditBalance object from a response
/// </summary>
/// <param name="element">The root element</param>
internal AddCreditBalance(XElement element)
{
if (element != null)
{
this.Amount = element.GetChildValueAsDecimal("Amount");
this.Currency = element.GetChildValue("Currency");
this.PaymentURL = new Uri(element.GetChildValue("PaymentURL"));
}
}
示例9: Payment
/// <summary>
/// Constructor from XML
/// </summary>
/// <param name="element"></param>
/// <param name="client"></param>
internal Payment(XElement element)
: this()
{
if (element != null)
{
this.Type = element.GetChildValue("PaymentType");
this.Description = element.GetChildValue("PaymentDescription");
this.Currency = element.GetChildValue("PaymentCurrency");
this.Amount = element.GetChildValueAsDecimal("PaymentAmount");
}
}
示例10: TestGetChildValue_SpecialCharacter
public void TestGetChildValue_SpecialCharacter()
{
var expect = "D<V>VC&PD IC";
var ele = new XElement("Root", new XElement("Test", expect, new XAttribute("attr",3.4), new XElement("Another", 5)));
var value = ele.GetChildValue("Test");
Assert.AreEqual(expect, value);
}
示例11: SourceLanguage
/// <summary>
/// Create a Source Language from XML
/// </summary>
/// <param name="element">The SourceLanguage parent element</param>
internal SourceLanguage(XElement element)
: this()
{
if (element != null)
{
this.LanguageCode = element.GetChildValue("LanguageCode");
}
}
示例12: Service
/// <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);
}
}
}
}
示例13: AssemblyReference
public AssemblyReference(XElement referenceElement)
{
ParseInclude(referenceElement);
ReferenceName = referenceElement.GetChildValue("Name");
HintPath = referenceElement.GetChildValue("HintPath");
SpecificVersion = GetChildBooleanValue(referenceElement, true, "SpecificVersion");
RequiredTargetFramework = TryParseFrameworkVersion(referenceElement.GetChildValue("RequiredTargetFramework"));
Private = GetChildBooleanValue(referenceElement, false, "Private");
ExecutableExtension = referenceElement.GetChildValue("ExecutableExtension");
FusionName = referenceElement.GetChildValue("FusionName");
Aliases = referenceElement.GetChildValue("Aliases");
}
示例14: Account
/// <summary>
/// Create an account from XML
/// </summary>
/// <param name="element"></param>
internal Account(XElement element)
: this()
{
if (element != null)
{
this.MerchantID = element.GetChildValue("MerchantID");
this.Status = element.GetChildValue("Status");
this.Email = element.GetChildValue("EmailAddress");
this.FirstName = element.GetChildValue("FirstName");
this.LastName= element.GetChildValue("LastName");
this.CompanyName = element.GetChildValue("CompanyName");
this.Country = element.GetChildValue("Country");
this.AccessKeyID = element.GetChildValue("AccessKeyID");
this.SecretAccessKey = element.GetChildValue("SecretAccessKey");
}
}
示例15: Estimate
/// <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");
}
}