本文整理匯總了C#中System.Xml.XmlTextReader.ReadElementContentAsDateTime方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadElementContentAsDateTime方法的具體用法?C# XmlTextReader.ReadElementContentAsDateTime怎麽用?C# XmlTextReader.ReadElementContentAsDateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadElementContentAsDateTime方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ReadXml
internal override void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
if (reader.Name == "note" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType != XmlNodeType.Element) continue;
string href;
switch (reader.Name)
{
case "account":
href = reader.GetAttribute("href");
if (null != href)
AccountCode = Uri.UnescapeDataString(href.Substring(href.LastIndexOf("/") + 1));
break;
case "message":
Message = reader.ReadElementContentAsString();
break;
case "created_at":
CreatedAt = reader.ReadElementContentAsDateTime();
break;
}
}
}
示例2: ReadXml
internal override void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
if (reader.Name == "account" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType != XmlNodeType.Element) continue;
switch (reader.Name)
{
case "account_code":
AccountCode = reader.ReadElementContentAsString();
break;
case "state":
// TODO investigate in case of incoming data representing multiple states, as https://dev.recurly.com/docs/get-account says is possible
State = reader.ReadElementContentAsString().ParseAsEnum<AccountState>();
break;
case "username":
Username = reader.ReadElementContentAsString();
break;
case "email":
Email = reader.ReadElementContentAsString();
break;
case "first_name":
FirstName = reader.ReadElementContentAsString();
break;
case "last_name":
LastName = reader.ReadElementContentAsString();
break;
case "company_name":
CompanyName = reader.ReadElementContentAsString();
break;
case "vat_number":
VatNumber = reader.ReadElementContentAsString();
break;
case "tax_exempt":
TaxExempt = reader.ReadElementContentAsBoolean();
break;
case "entity_use_code":
EntityUseCode = reader.ReadElementContentAsString();
break;
case "accept_language":
AcceptLanguage = reader.ReadElementContentAsString();
break;
case "hosted_login_token":
HostedLoginToken = reader.ReadElementContentAsString();
break;
case "created_at":
CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "address":
Address = new Address(reader);
break;
case "vat_location_valid":
if (reader.GetAttribute("nil") == null)
{
VatLocationValid = reader.ReadElementContentAsBoolean();
}
break;
}
}
}
示例3: Main
static void Main(string[] args)
{
var filePath = args.First();
Program.ResourceLock = new SemaphoreSlim(15);
var elasticSettings = new ConnectionSettings("127.0.0.1.", 9200)
.SetDefaultIndex("mpdreamz")
.SetMaximumAsyncConnections(50);
var client = new ElasticClient(elasticSettings);
ConnectionStatus connectionStatus;
if (!client.TryConnect(out connectionStatus))
{
Console.Error.WriteLine("Could not connect to {0}:\r\n{1}",
elasticSettings.Host, connectionStatus.Error.OriginalException.Message);
Console.Read();
return;
}
var reader = new XmlTextReader(filePath);
Post post = new Post();
PostMetaData meta = new PostMetaData();
int processed = 0, dropped = 0;
Stopwatch sw = new Stopwatch();
sw.Start();
var postQueue = new List<Post>();
try
{
while (reader.Read())
{
var name = reader.Name;
if (reader.NodeType == XmlNodeType.Element)
{
if (name == "HackerNews")
continue;
if (name == "ID")
post.Id = reader.ReadElementContentAsInt();
else if (name == "ParentID")
post.ParentId = reader.ReadElementContentAsInt();
else if (name == "Url")
post.Url = reader.ReadElementContentAsString();
else if (name == "Title")
post.Title = reader.ReadElementContentAsString();
else if (name == "Text")
post.Text = reader.ReadElementContentAsString();
else if (name == "Username")
meta.Username = reader.ReadElementContentAsString();
else if (name == "Points")
meta.Points = reader.ReadElementContentAsInt();
else if (name == "Type")
meta.Type = reader.ReadElementContentAsInt();
else if (name == "Timestamp")
meta.Created = reader.ReadElementContentAsDateTime();
else if (name == "CommentCount")
meta.CommentsCount = reader.ReadElementContentAsInt();
}
if (reader.NodeType == XmlNodeType.EndElement
&& name == "row")
{
post.Meta = meta;
postQueue.Add(post);
if (postQueue.Count() == 1000)
{
client.IndexAsync<Post>(postQueue, (c) =>
{
if (!c.Success)
dropped++;
});
postQueue = new List<Post>();
processed++;
}
Console.Write("\rProcessed:{0}, Dropped:{2} in {1}", processed, sw.Elapsed, dropped);
post = new Post();
meta = new PostMetaData();
}
}
sw.Stop();
Console.WriteLine("\nDone! {0}", sw.Elapsed);
}
catch (Exception e)
{
}
}
示例4: ReadXml
internal override void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
// End of account element, get out of here
if (reader.Name == "adjustment" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType != XmlNodeType.Element) continue;
switch (reader.Name)
{
case "account":
var href = reader.GetAttribute("href");
AccountCode = Uri.UnescapeDataString(href.Substring(href.LastIndexOf("/") + 1));
break;
case "uuid":
Uuid = reader.ReadElementContentAsString();
break;
case "description":
Description = reader.ReadElementContentAsString();
break;
case "accounting_code":
AccountingCode = reader.ReadElementContentAsString();
break;
case "origin":
Origin = reader.ReadElementContentAsString();
break;
case "unit_amount_in_cents":
UnitAmountInCents = reader.ReadElementContentAsInt();
break;
case "quantity":
Quantity = reader.ReadElementContentAsInt();
break;
case "discount_in_cents":
DiscountInCents = reader.ReadElementContentAsInt();
break;
case "tax_in_cents":
TaxInCents = reader.ReadElementContentAsInt();
break;
case "total_in_cents":
TotalInCents = reader.ReadElementContentAsInt();
break;
case "currency":
Currency = reader.ReadElementContentAsString();
break;
case "tax_exempt":
TaxExempt = reader.ReadElementContentAsBoolean();
break;
case "start_date":
StartDate = reader.ReadElementContentAsDateTime();
break;
case "end_date":
DateTime endDate;
if (DateTime.TryParse(reader.ReadElementContentAsString(), out endDate))
EndDate = endDate;
break;
case "created_at":
CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "state":
State = reader.ReadElementContentAsString().ParseAsEnum<AdjustmentState>();
break;
}
}
}
示例5: ReadXml
internal void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
// End of account element, get out of here
if (reader.Name == "adjustment" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "account":
string href = reader.GetAttribute("href");
this.AccountCode = Uri.UnescapeDataString(href.Substring(href.LastIndexOf("/") + 1));
break;
case "uuid":
this.Uuid = reader.ReadElementContentAsString();
break;
case "description":
this.Description = reader.ReadElementContentAsString();
break;
case "accounting_code":
this.AccountingCode = reader.ReadElementContentAsString();
break;
case "origin":
this.Origin = reader.ReadElementContentAsString();
break;
case "unit_amount_in_cents":
this.UnitAmountInCents = reader.ReadElementContentAsInt();
break;
case "quantity":
this.Quantity = reader.ReadElementContentAsInt();
break;
case "discount_in_cents":
this.DiscountInCents = reader.ReadElementContentAsInt();
break;
case "tax_in_cents":
this.TaxInCents = reader.ReadElementContentAsInt();
break;
case "total_in_cents":
this.TotalInCents = reader.ReadElementContentAsInt();
break;
case "currency":
this.Currency = reader.ReadElementContentAsString();
break;
case "taxable":
this.Taxable = reader.ReadElementContentAsBoolean();
break;
case "start_date":
this.StartDate = reader.ReadElementContentAsDateTime();
break;
case "end_date":
DateTime endDate;
if (DateTime.TryParse(reader.ReadElementContentAsString(), out endDate))
this.EndDate = endDate;
break;
case "created_at":
this.CreatedAt = reader.ReadElementContentAsDateTime();
break;
}
}
}
}
示例6: Main
/// <summary>
/// Depends on hn_full_11-07-2010.xml which you can download from:
/// http://api.ihackernews.com/torrents/hn_full_11-07-2010.zip.torrent
///
/// When run from debug make sure to change the default debug arguments.
/// <param name="args">Full filepath to hn_full_11-07-2010.xml</param>
static void Main(string[] args)
{
var filePath = args.First();
var elasticSettings = new ConnectionSettings(new Uri("http://ipv4.fiddler:9200"))
.SetDefaultIndex("mpdreamz")
.SetMaximumAsyncConnections(50);
var client = new ElasticClient(elasticSettings);
ConnectionStatus connectionStatus;
if (!client.TryConnect(out connectionStatus))
{
Console.Error.WriteLine("Could not connect to {0}:\r\n{1}",
elasticSettings.Host, connectionStatus.Error.OriginalException.Message);
Console.Read();
return;
}
var reader = new XmlTextReader(filePath);
Post post = new Post();
PostMetaData meta = new PostMetaData();
int processed = 0, dropped = 0;
Stopwatch sw = new Stopwatch();
sw.Start();
var postQueue = new List<Post>();
try
{
while (reader.Read())
{
var name = reader.Name;
if (reader.NodeType == XmlNodeType.Element)
{
if (name == "HackerNews")
continue;
if (name == "ID")
post.Id = reader.ReadElementContentAsInt();
else if (name == "ParentID")
post.ParentId = reader.ReadElementContentAsInt();
else if (name == "Url")
post.Url = reader.ReadElementContentAsString();
else if (name == "Title")
post.Title = reader.ReadElementContentAsString();
else if (name == "Text")
post.Text = reader.ReadElementContentAsString();
else if (name == "Username")
meta.Username = reader.ReadElementContentAsString();
else if (name == "Points")
meta.Points = reader.ReadElementContentAsInt();
else if (name == "Type")
meta.Type = reader.ReadElementContentAsInt();
else if (name == "Timestamp")
meta.Created = reader.ReadElementContentAsDateTime();
else if (name == "CommentCount")
meta.CommentsCount = reader.ReadElementContentAsInt();
}
if (reader.NodeType == XmlNodeType.EndElement
&& name == "row")
{
post.Meta = meta;
postQueue.Add(post);
if (postQueue.Count() == 1000)
{
var t = client.IndexManyAsync(postQueue);
t.ContinueWith(c =>
{
var result = c.Result;
if (!result.IsValid)
dropped++;
});
processed += postQueue.Count();
postQueue = new List<Post>();
}
Console.Write("\rProcessed:{0}, Dropped:{2} in {1}", processed, sw.Elapsed, dropped);
post = new Post();
meta = new PostMetaData();
}
}
if (postQueue.Count() > 0)
{
var task = client.IndexManyAsync(postQueue).ContinueWith(t =>
{
var c = t.Result;
if (!c.IsValid)
Interlocked.Increment(ref dropped);
return t;
});
Interlocked.Add(ref processed, postQueue.Count());
postQueue = new List<Post>();
//.........這裏部分代碼省略.........
示例7: ReadXml
internal void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
// End of account element, get out of here
if (reader.Name == "add_on" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "add_on_code":
this.AddOnCode = reader.ReadElementContentAsString();
break;
case "name":
this.Name = reader.ReadElementContentAsString();
break;
case "display_quantity_on_hosted_page":
this.DisplayQuantityOnHostedPage = reader.ReadElementContentAsBoolean();
break;
case "default_quantity":
this.DefaultQuantity = reader.ReadElementContentAsInt();
break;
case "created_at":
this.CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "unit_amount_in_cents":
ReadXmlUnitAmount(reader);
break;
}
}
}
}
示例8: ReadXml
internal void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
// End of account element, get out of here
if (reader.Name == "plan" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "plan_code":
this.PlanCode = reader.ReadElementContentAsString();
break;
case "name":
this.Name = reader.ReadElementContentAsString();
break;
case "description":
this.Description = reader.ReadElementContentAsString();
break;
case "success_url":
this.SuccessUrl = reader.ReadElementContentAsString();
break;
case "cancel_url":
this.CancelUrl = reader.ReadElementContentAsString();
break;
case "display_donation_amounts":
this.DisplayDonationAmounts = reader.ReadElementContentAsBoolean();
break;
case "display_quantity":
this.DisplayQuantity = reader.ReadElementContentAsBoolean();
break;
case "display_phone_number":
this.DisplayPhoneNumber = reader.ReadElementContentAsBoolean();
break;
case "bypass_hosted_confirmation":
this.BypassHostedConfirmation = reader.ReadElementContentAsBoolean();
break;
case "unit_name":
this.UnitName = reader.ReadElementContentAsString();
break;
case "payment_page_tos_link":
this.PaymentPageTOSLink = reader.ReadElementContentAsString();
break;
case "plan_interval_length":
this.PlanIntervalLength = reader.ReadElementContentAsInt();
break;
case "plan_interval_unit":
this.PlanIntervalUnit = (IntervalUnit)Enum.Parse(typeof(IntervalUnit), reader.ReadElementContentAsString(), true);
break;
case "trial_interval_length":
this.TrialIntervalLength = reader.ReadElementContentAsInt();
break;
case "trial_interval_unit":
this.TrialIntervalUnit = (IntervalUnit)Enum.Parse(typeof(IntervalUnit), reader.ReadElementContentAsString(), true);
break;
case "accounting_code":
this.AccountingCode = reader.ReadElementContentAsString();
break;
case "created_at":
this.CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "unit_amount_in_cents":
ReadXmlUnitAmount(reader);
break;
case "setup_fee_in_cents":
ReadXmlSetupFee(reader);
break;
}
}
}
}
示例9: ReadXml
internal override void ReadXml(XmlTextReader reader)
{
UnitAmountInCents.Clear();
SetupFeeInCents.Clear();
while (reader.Read())
{
// End of account element, get out of here
if (reader.Name == "plan" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType != XmlNodeType.Element) continue;
switch (reader.Name)
{
case "plan_code":
PlanCode = reader.ReadElementContentAsString();
break;
case "name":
Name = reader.ReadElementContentAsString();
break;
case "description":
Description = reader.ReadElementContentAsString();
break;
case "success_url":
SuccessUrl = reader.ReadElementContentAsString();
break;
case "cancel_url":
CancelUrl = reader.ReadElementContentAsString();
break;
case "display_donation_amounts":
DisplayDonationAmounts = reader.ReadElementContentAsBoolean();
break;
case "display_quantity":
DisplayQuantity = reader.ReadElementContentAsBoolean();
break;
case "display_phone_number":
DisplayPhoneNumber = reader.ReadElementContentAsBoolean();
break;
case "bypass_hosted_confirmation":
BypassHostedConfirmation = reader.ReadElementContentAsBoolean();
break;
case "unit_name":
UnitName = reader.ReadElementContentAsString();
break;
case "payment_page_tos_link":
PaymentPageTOSLink = reader.ReadElementContentAsString();
break;
case "plan_interval_length":
PlanIntervalLength = reader.ReadElementContentAsInt();
break;
case "plan_interval_unit":
PlanIntervalUnit = reader.ReadElementContentAsString().ParseAsEnum<IntervalUnit>();
break;
case "trial_interval_length":
TrialIntervalLength = reader.ReadElementContentAsInt();
break;
case "trial_interval_unit":
TrialIntervalUnit = reader.ReadElementContentAsString().ParseAsEnum<IntervalUnit>();
break;
case "accounting_code":
AccountingCode = reader.ReadElementContentAsString();
break;
case "created_at":
CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "tax_exempt":
TaxExempt = reader.ReadElementContentAsBoolean();
break;
case "unit_amount_in_cents":
ReadXmlUnitAmount(reader);
break;
case "setup_fee_in_cents":
ReadXmlSetupFee(reader);
break;
}
}
}
示例10: ReadXml
//.........這裏部分代碼省略.........
string invoiceNumber = href.Substring(href.LastIndexOf("/") + 1);
MatchCollection matches = Regex.Matches(invoiceNumber, "([^\\d]{2})(\\d+)");
if (matches.Count == 1)
{
InvoicePrefix = matches[0].Groups[1].Value;
Invoice = int.Parse(matches[0].Groups[2].Value);
}
else
{
Invoice = int.Parse(invoiceNumber);
}
}
break;
case "uuid":
Uuid = reader.ReadElementContentAsString();
break;
case "action":
Action = reader.ReadElementContentAsString().ParseAsEnum<TransactionType>();
break;
case "amount_in_cents":
if (Int32.TryParse(reader.ReadElementContentAsString(), out amount))
AmountInCents = amount;
break;
case "tax_in_cents":
if (Int32.TryParse(reader.ReadElementContentAsString(), out amount))
TaxInCents = amount;
break;
case "currency":
Currency = reader.ReadElementContentAsString();
break;
case "description":
Description = reader.ReadElementContentAsString();
break;
case "payment_method":
PaymentMethod = reader.ReadElementContentAsString();
break;
case "status":
var state = reader.ReadElementContentAsString();
Status = "void" == state ? TransactionState.Voided : state.ParseAsEnum<TransactionState>();
break;
case "reference":
Reference = reader.ReadElementContentAsString();
break;
case "test":
Test = reader.ReadElementContentAsBoolean();
break;
case "voidable":
Voidable = reader.ReadElementContentAsBoolean();
break;
case "refundable":
Refundable = reader.ReadElementContentAsBoolean();
break;
case "ip_address":
IpAddress = reader.ReadElementContentAsString();
break;
case "ccv_result":
CCVResult = reader.ReadElementContentAsString();
break;
case "avs_result":
AvsResult = reader.ReadElementContentAsString();
break;
case "avs_result_street":
AvsResultStreet = reader.ReadElementContentAsString();
break;
case "avs_result_postal":
AvsResultPostal = reader.ReadElementContentAsString();
break;
case "created_at":
CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "updated_at":
UpdatedAt = reader.ReadElementContentAsDateTime();
break;
case "details":
// API docs say not to load details into objects
break;
}
}
}
示例11: FromStream
public static Plate FromStream(Stream stream)
{
var reader = new XmlTextReader(stream);
IPlateType plateType = null;
DateTime created = DateTime.Today;
DateTime lastChanged = DateTime.Now;
var items = new List<string>();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == "Type")
{
var typeName = reader.GetAttribute("FullName");
if (typeName != null)
{
var typeType = System.Type.GetType(typeName);
if (typeType != null) plateType = (IPlateType)Activator.CreateInstance(typeType);
}
if (plateType != null)
{
reader.Read();
plateType.FromXml(reader);
}
} else if (reader.Name == "Content")
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "Well")
{
items.Add(reader.ReadElementContentAsString());
} else if (reader.NodeType == XmlNodeType.EndElement)
{
reader.ReadEndElement();
break;
}
}
} else if (reader.Name == "Created")
{
created = reader.ReadElementContentAsDateTime();
} else if (reader.Name == "LastChanged")
{
lastChanged = reader.ReadElementContentAsDateTime();
}
} else if (reader.NodeType == XmlNodeType.EndElement)
{
if (reader.Name == "Plate")
{
reader.ReadEndElement();
break;
}
}
}
if (plateType != null)
{
var plate = new Plate(plateType);
var format = plate.Type.Format;
for (int i = 0; i < plate.Content.Length; i++)
{
plate.Content[i] = new Well(items[i], i / format.Width, i % format.Width);
}
plate.Created = created;
plate.LastChanged = lastChanged;
return plate;
}
return null;
}
示例12: getAppointments
private void getAppointments()
{
//Build the Connection String
UriBuilder ub = new UriBuilder();
StringBuilder data = new StringBuilder();
data.Append("u=" + WebUtility.HtmlEncode(sessionManager.User));
data.Append("&key=" + WebUtility.HtmlEncode(sessionManager.Key));
ub.Host = "67.10.181.224/~cookie/emis-dev/Appointments.php";
ub.Query = data.ToString();
//Create the request
Uri requestUri = ub.Uri;
WebRequest request = WebRequest.Create(requestUri);
request.Method = "GET";
try
{
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
XmlTextReader xmlReader = new XmlTextReader(response.GetResponseStream());
while (xmlReader.Read())
{
switch (xmlReader.NodeType)
{
case XmlNodeType.Element:
if (xmlReader.Name == "appt")
{
Appt newAppt = new Appt();
xmlReader.Read();
switch (xmlReader.Name)
{
case "date":
newAppt.AppointmentTime = xmlReader.ReadElementContentAsDateTime();
break;
case "time":
DateTime time = xmlReader.ReadElementContentAsDateTime();
newAppt.AppointmentTime.AddHours(time.Hour);
newAppt.AppointmentTime.AddMinutes(time.Minute);
break;
default:
break;
}
appointments.Add(newAppt);
}
break;
default:
break;
}
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message, "Yeah...we didn't plan for this", MessageBoxButtons.OK);
Application.Exit();
}
}
示例13: ReadXml
internal override void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
// End of account element, get out of here
if (reader.Name == "add_on" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType != XmlNodeType.Element) continue;
switch (reader.Name)
{
case "add_on_code":
AddOnCode = reader.ReadElementContentAsString();
break;
case "accounting_code":
AccountingCode = reader.ReadElementContentAsString();
break;
case "name":
Name = reader.ReadElementContentAsString();
break;
case "display_quantity_on_hosted_page":
DisplayQuantityOnHostedPage = reader.ReadElementContentAsBoolean();
break;
case "default_quantity":
DefaultQuantity = reader.ReadElementContentAsInt();
break;
case "optional":
Optional = reader.ReadElementContentAsBoolean();
break;
case "created_at":
CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "updated_at":
UpdatedAt = reader.ReadElementContentAsDateTime();
break;
case "unit_amount_in_cents":
ReadXmlUnitAmount(reader);
break;
case "tax_code":
TaxCode = reader.ReadElementContentAsString();
break;
case "add_on_type":
AddOnType = reader.ReadElementContentAsString().ParseAsEnum<Type>();
break;
case "usage_type":
UsageType = reader.ReadElementContentAsString().ParseAsEnum<Usage.Type>();
break;
}
}
}
示例14: ReadXml
internal void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
// End of invoice element, get out of here
if (reader.Name == "invoice" && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "account":
string href = reader.GetAttribute("href");
this.AccountCode = Uri.UnescapeDataString(href.Substring(href.LastIndexOf("/") + 1));
break;
case "uuid":
this.Uuid = reader.ReadElementContentAsString();
break;
case "state":
this.State = (InvoiceState)Enum.Parse(typeof(InvoiceState), reader.ReadElementContentAsString(), true);
break;
case "invoice_number":
int invNumber;
if (Int32.TryParse(reader.ReadElementContentAsString(), out invNumber))
this.InvoiceNumber = invNumber;
break;
case "po_number":
this.PONumber = reader.ReadElementContentAsString();
break;
case "vat_number":
this.VatNumber = reader.ReadElementContentAsString();
break;
case "subtotal_in_cents":
this.SubtotalInCents = reader.ReadElementContentAsInt();
break;
case "tax_in_cents":
this.TaxInCents = reader.ReadElementContentAsInt();
break;
case "total_in_cents":
this.TotalInCents = reader.ReadElementContentAsInt();
break;
case "currency":
this.Currency = reader.ReadElementContentAsString();
break;
case "created_at":
this.CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "line_items":
Adjustments.ReadXml(reader);
break;
case "transactions":
Transactions.ReadXml(reader);
break;
}
}
}
}
示例15: ReadXml
internal override void ReadXml(XmlTextReader reader)
{
while (reader.Read())
{
// End of coupon element, get out of here
if ((reader.Name == "coupon" || reader.Name == "redemption") && reader.NodeType == XmlNodeType.EndElement)
break;
if (reader.NodeType != XmlNodeType.Element) continue;
string href;
switch (reader.Name)
{
case "uuid":
Uuid = reader.ReadElementContentAsString();
break;
case "account":
href = reader.GetAttribute("href");
AccountCode = Uri.UnescapeDataString(href.Substring(href.LastIndexOf("/") + 1));
break;
case "coupon":
href = reader.GetAttribute("href");
CouponCode =Uri.UnescapeDataString( href.Substring(href.LastIndexOf("/") + 1));
break;
case "single_use":
SingleUse = reader.ReadElementContentAsBoolean();
break;
case "total_discounted_in_cents":
int discountInCents;
if (Int32.TryParse(reader.ReadElementContentAsString(), out discountInCents))
TotalDiscountedInCents = discountInCents;
break;
case "currency":
Currency = reader.ReadElementContentAsString();
break;
case "state":
State = reader.ReadElementContentAsString();
break;
case "subscription_uuid":
SubscriptionUuid = reader.ReadElementContentAsString();
break;
case "created_at":
CreatedAt = reader.ReadElementContentAsDateTime();
break;
case "updated_at":
CreatedAt = reader.ReadElementContentAsDateTime();
break;
}
}
}