本文整理匯總了C#中System.Xml.XmlTextReader.ReadElementContentAsBoolean方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.ReadElementContentAsBoolean方法的具體用法?C# XmlTextReader.ReadElementContentAsBoolean怎麽用?C# XmlTextReader.ReadElementContentAsBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadElementContentAsBoolean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: loadState
private void loadState(XmlFile stateXml)
{
XmlTextReader textReader = new XmlTextReader(stateXml.fileName);
textReader.ReadToFollowing("lightsAndSoundOn");
lightsAndSoundOn = textReader.ReadElementContentAsBoolean();
textReader.ReadToFollowing("safeToDisableChoreo");
safeToDisableChoreo = textReader.ReadElementContentAsBoolean();
textReader.Close();
}
示例2: ReadFromXML
public static void ReadFromXML(ref XmlTextReader reader)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == XMLPropNames.strAbility)
{
if (XMLPropNames.strGrandSlam == reader.GetAttribute(XMLPropNames.strName))
ReadGrandSlamAbility(ref reader);
else if (XMLPropNames.strSuperKnockBack == reader.GetAttribute(XMLPropNames.strName))
ReadSuperKnockBackAbility(ref reader);
else if (XMLPropNames.strRoar == reader.GetAttribute(XMLPropNames.strName))
ReadRoarAbility(ref reader);
else if (XMLPropNames.strTornado == reader.GetAttribute(XMLPropNames.strName))
ReadTornadoAbility(ref reader);
}
else if (reader.Name == XMLPropNames.strInitialization)
ReadInitialization(ref reader);
else if (reader.Name == XMLPropNames.strVariableSize)
mVariableSize = reader.ReadElementContentAsBoolean();
}
else if (reader.NodeType == XmlNodeType.EndElement &&
reader.Name == XMLPropNames.strAgentProperties)
break;
}
}
示例3: loadPreferences
// be careful - have to read nodes in the order they are written!
private void loadPreferences(XmlFile prefsXml)
{
XmlTextReader textReader = new XmlTextReader(prefsXml.fileName);
textReader.ReadToFollowing("minimizeToSystemTray");
minimizePref.Checked = textReader.ReadElementContentAsBoolean();
textReader.Close();
}
示例4: ReadXmlFile
/// <summary>
/// Determinates which version of the xml if this current file, and read color and opacity function from it.
/// </summary>
/// <param name="fileName">Name of the preset</param>
/// <returns>Information about the preset, which includes series of color and opacity function</returns>
public PresetInformation ReadXmlFile(String fileName)
{
try
{
_reader = new XmlTextReader(Path.Combine(Directory.GetCurrentDirectory(), @"presety\", fileName));
_reader.ReadToFollowing("IndependentColor");
Boolean isIndependent = _reader.ReadElementContentAsBoolean();
if (isIndependent)
{
return ReadOpacityFunction(fileName, ReadColorFunction());
}
return ReadOpacityAndColorFunction();
}
catch (Exception e)
{
logger.ErrorException("Preset file reading exception: "+e.Message, e);
logger.Warn(Path.Combine(Directory.GetCurrentDirectory(), @"presety\", fileName));
return new PresetInformation();
}
}
示例5: Read
public List<DanbooruProvider> Read(string filename = @"DanbooruProviderList.xml")
{
List<DanbooruProvider> list = new List<DanbooruProvider>();
using (XmlTextReader reader = new XmlTextReader(filename))
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.Name.Equals("DanbooruProviderList")) break;
else if (reader.Name.Equals("DanbooruProvider"))
{
Console.WriteLine(reader.Value);
DanbooruProvider newProvider = new DanbooruProvider();
do
{
reader.Read();
if (reader.NodeType.Equals(XmlNodeType.Element))
{
switch (reader.Name)
{
case "Name": newProvider.Name = reader.ReadElementContentAsString(); break;
case "Url": newProvider.Url = reader.ReadElementContentAsString(); break;
case "QueryStringJson": newProvider.QueryStringJson = reader.ReadElementContentAsString(); break;
case "QueryStringHtml": newProvider.QueryStringHtml = reader.ReadElementContentAsString(); break;
case "QueryStringXml": newProvider.QueryStringXml = reader.ReadElementContentAsString(); break;
case "Preferred":
string preferred = reader.ReadElementContentAsString().ToLowerInvariant();
switch (preferred)
{
case "json":
newProvider.Preferred = PreferredMethod.Json;
break;
case "xml":
newProvider.Preferred = PreferredMethod.Xml;
break;
case "html":
newProvider.Preferred = PreferredMethod.Html;
break;
default:
throw new Exception("Invalid Provider Type in DanbooruProviderList.xml: " + preferred);
}
break;
case "DefaultLimit": newProvider.DefaultLimit = reader.ReadElementContentAsInt(); break;
case "HardLimit": newProvider.HardLimit = reader.ReadElementContentAsInt(); break;
case "UserName": newProvider.UserName = reader.ReadElementContentAsString(); break;
case "Password": newProvider.Password = reader.ReadElementContentAsString(); break;
case "UseAuth": newProvider.UseAuth = reader.ReadElementContentAsBoolean(); break;
case "PasswordSalt": newProvider.PasswordSalt = reader.ReadElementContentAsString(); break;
case "PasswordHash": newProvider.PasswordHash = reader.ReadElementContentAsString(); break;
case "BoardType":
string type = reader.ReadElementContentAsString();
newProvider.BoardType = (BoardType)Enum.Parse(typeof(BoardType), type); //Type.Equals("Danbooru") ? BoardType.Danbooru:BoardType.Gelbooru ;
break;
case "TagDownloadUseLoop": newProvider.TagDownloadUseLoop = reader.ReadElementContentAsBoolean(); break;
default: break;
}
}
} while (!reader.Name.Equals("DanbooruProvider"));
list.Add(newProvider);
}
break;
default: break;
}
}
}
return list;
}
示例6: ReadXmlFile
/// <summary>
/// Determinates which version of the xml if this current file, and read color and opacity function from it.
/// </summary>
/// <param name="fileName">Name of the preset</param>
/// <returns>Information about the preset, which includes series of color and opacity function</returns>
public PresetInformation ReadXmlFile(String fileName)
{
_reader = new XmlTextReader(Path.Combine(@"..\..\presety\",fileName));
_reader.ReadToFollowing("IndependentColor");
Boolean isIndependent = _reader.ReadElementContentAsBoolean();
if (isIndependent)
{
return ReadOpacityFunction(fileName, ReadColorFunction());
}
return ReadOpacityAndColorFunction();
}
示例7: ProcessPassTouches
private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader)
{
obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty);
}
示例8: ProcessShpSculptEntry
private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader)
{
shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty);
}
示例9: Parse
private Compiler Parse(string xmlFilePath)
{
var compiler = new Compiler();
var xmlReader = new XmlTextReader(xmlFilePath);
xmlReader.Read();
while (xmlReader.Read())
{
switch (xmlReader.Name)
{
case "name":
{
compiler.Name = xmlReader.ReadElementContentAsString();
}
break;
case "location":
{
compiler.Location = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory, xmlReader.ReadElementContentAsString());
}
break;
case "extension":
{
compiler.Extension = xmlReader.ReadElementContentAsString().TrimEnd().TrimStart();
}
break;
case "arguments":
{
compiler.Arguments = xmlReader.ReadElementContentAsString().TrimEnd().TrimStart();
}
break;
case "compiledExtension":
{
compiler.CompiledExtension = xmlReader.ReadElementContentAsString().TrimEnd().TrimStart();
}
break;
case "needShortName":
{
compiler.IsNeedShortPath = xmlReader.ReadElementContentAsBoolean();
}
break;
}
}
if (compiler.Extension == string.Empty || compiler.Name == string.Empty || compiler.Location == string.Empty || compiler.CompiledExtension == string.Empty || compiler.Arguments == string.Empty)
throw new Exception("Bad xml information about compiler");
return compiler;
}
示例10: 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;
}
}
}
}
示例11: 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":
DateTime date;
if (DateTime.TryParse(reader.ReadElementContentAsString(), out date))
CreatedAt = date;
break;
}
}
}
示例12: 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;
}
}
}
示例13: 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;
}
}
}
}
示例14: Text
/// <summary>
/// Hier wird der Knoten Text ausgewertet
/// Es wird ein neues Text Objekt instanziiert und die entsprechenden Eigenschaften übergeben
/// Falls eine Exception beim Casten der Werte geworfen wird, wird diese gefangen und weitergeleitet
/// Bei erfolreicher Erstellung des Objekts wird dieses in dem Word Dokument eingefügt
/// </summary>
/// <param name="xml">Der Parameter beinhaltet einen Textknoten mit all seinen Unterknoten</param>
public void Text(string xml)
{
XmlTextReader subReader = new XmlTextReader(new System.IO.StringReader(xml));
Text text = new Text();
while (subReader.Read())
{
if (subReader.NodeType == XmlNodeType.Element)
{
switch (subReader.Name)
{
case "string":
text.Content = subReader.ReadElementContentAsString();
break;
case "font":
text.Font = subReader.ReadElementString();
break;
case "size":
try
{
text.Size = subReader.ReadElementContentAsInt();
}
catch (XmlException e)
{
subReader.Close();
throw new OpenDocumentException(e.Message);
}
break;
case "paragraph":
try
{
text.Paragraph = subReader.ReadElementContentAsInt();
}
catch (XmlException e)
{
subReader.Close();
throw new OpenDocumentException(e.Message);
}
break;
case "style":
try
{
text.Style = subReader.ReadElementContentAsInt();
}
catch (XmlException e)
{
subReader.Close();
throw new OpenDocumentException(e.Message);
}
break;
case "color":
text.Color = subReader.ReadElementString();
break;
case "pageBreak":
try
{
text.PageBreak = subReader.ReadElementContentAsBoolean();
}
catch (XmlException e)
{
subReader.Close();
throw new OpenDocumentException(e.Message);
}
break;
}
}
}
subReader.Close();
doc.Text(text);
}
示例15: Tabelle
/// <summary>
/// Dient zur Auswertung des Knoten Tabelle
/// Es wird eine Tabellen Objekt instanziiert und die entsprechenden Eigenschaften übernommen.
/// Falls eine Exception beim Casten der Werte geworfen wird, wird diese gefangen und weitergeleitet
/// Bei erfolgreicher Erstellung des Objekts wird der Tabelleninhalt über eine Datenbankanbindung abgefragt.
/// Falls eine Exception bei der Abfrage geworfen wird, wird diese gefangen und weitergeleitet.
/// Bei erfolgreicher Abfrage wird die Tabelle im Word Dokument hinzugefügt
/// </summary>
/// <param name="xml"></param>
public void Tabelle(string xml)
{
XmlTextReader subReader = new XmlTextReader(new System.IO.StringReader(xml));
Tabelle table = new Tabelle();
while (subReader.Read())
{
if (subReader.NodeType == XmlNodeType.Element)
{
switch (subReader.Name)
{
case "id":
table.Id = subReader.ReadElementString();
break;
case "bold":
try
{
table.Bold = subReader.ReadElementContentAsBoolean();
}
catch (XmlException e)
{
subReader.Close();
throw new OpenDocumentException(e.Message);
}
break;
case "background":
table.BgColor = subReader.ReadElementString();
break;
case "sql":
table.Text = subReader.ReadElementString();
break;
case "border":
try
{
table.Border = subReader.ReadElementContentAsBoolean();
}
catch (XmlException e)
{
subReader.Close();
throw new OpenDocumentException(e.Message);
}
break;
case "font":
table.Font = subReader.ReadElementString();
break;
case "size":
try
{
table.Size = subReader.ReadElementContentAsInt();
}
catch (XmlException e)
{
subReader.Close();
throw new OpenDocumentException(e.Message);
}
break;
case "paragraph":
try
{
table.Paragraph = subReader.ReadElementContentAsInt();
}
catch (XmlException e)
{
subReader.Close();
throw new OpenDocumentException(e.Message);
}
break;
}
}
}
subReader.Close();
try
{
table.getContent(connections);
}
catch (MySql.Data.MySqlClient.MySqlException e)
{
throw new OpenDocumentException(e.Message);
}
catch (System.Data.SqlClient.SqlException e)
{
throw new OpenDocumentException(e.Message);
}
catch (InvalidCastException)
{
throw new OpenDocumentException("Datenbankverbindung " + table.Id + " für Tabelle mit Abfrage " + table.Text + " nicht gefunden");
}
catch (Exception e)
{
throw new OpenDocumentException(e.Message);
}
doc.Table(table);
//.........這裏部分代碼省略.........