本文整理汇总了C#中System.Xml.XmlReader类的典型用法代码示例。如果您正苦于以下问题:C# XmlReader类的具体用法?C# XmlReader怎么用?C# XmlReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlReader类属于System.Xml命名空间,在下文中一共展示了XmlReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform
/// <summary>
/// Applies the transformation from the reader to the writer
/// </summary>
/// <param name="reader"></param>
/// <param name="writer"></param>
public void Transform(XmlReader reader, XmlWriter writer) {
Contract.Requires(reader != null);
Contract.Requires(writer != null);
while (reader.Read())
this.WriteNodeSingle(reader, writer);
}
示例2: while
void IFlickrParsable.Load(XmlReader reader)
{
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "id":
PhotoId = reader.Value;
break;
case "ispublic":
IsPublic = reader.Value == "1";
break;
case "iscontact":
IsContact = reader.Value == "1";
break;
case "isfamily":
IsFamily = reader.Value == "1";
break;
case "isfriend":
IsFriend = reader.Value == "1";
break;
}
}
reader.Read();
}
示例3: DeserializeNetwork
public override void DeserializeNetwork(XmlReader xmlReader)
{
base.DeserializeNetwork(xmlReader);
var expander = ControlElements[0] as SliderExpanderDouble;
if (expander == null) return;
var attribute = xmlReader.GetAttribute("SliderMax");
if (attribute != null)
expander.SliderMax = Convert.ToDouble(attribute.Replace(".", ","));
var attribute1 = xmlReader.GetAttribute("SliderMin");
if (attribute1 != null)
expander.SliderMin = Convert.ToDouble(attribute1.Replace(".", ","));
var attribute2 = xmlReader.GetAttribute("SliderValue");
if (attribute2 != null)
expander.SliderValue = Convert.ToDouble(attribute2.Replace(".", ","));
var attribute3 = xmlReader.GetAttribute("SliderStep");
if (attribute3 != null)
expander.SliderStep = Convert.ToDouble(attribute3.Replace(".", ","));
var attribute4 = xmlReader.GetAttribute("IsExpanded");
if (attribute4 != null)
expander.IsExpanded = Convert.ToBoolean(attribute4.Replace(".", ","));
}
示例4: TokenizeFromXml
public object TokenizeFromXml(XmlReader reader)
{
reader.ReadStartElement();
Geometry geometry = GmlFormatter.Create().Read<Geometry>(reader);
reader.SkipInsignificantNodes();
return geometry;
}
示例5: ReadTokenCore
protected override System.IdentityModel.Tokens.SecurityToken ReadTokenCore( XmlReader reader, SecurityTokenResolver tokenResolver )
{
if ( reader == null )
throw new ArgumentNullException( "reader" );
if ( reader.IsStartElement( Constants.UsernameTokenName, Constants.UsernameTokenNamespace ) )
{
//string id = reader.GetAttribute( Constants.IdAttributeName, Constants.WsUtilityNamespace );
reader.ReadStartElement();
// read the user name
string userName = reader.ReadElementString( Constants.UsernameElementName, Constants.UsernameTokenNamespace );
// read the password hash
string password = reader.ReadElementString( Constants.PasswordElementName, Constants.UsernameTokenNamespace );
// read nonce
string nonce = reader.ReadElementString( Constants.NonceElementName, Constants.UsernameTokenNamespace );
// read created
string created = reader.ReadElementString( Constants.CreatedElementName, Constants.WsUtilityNamespace );
reader.ReadEndElement();
var info = new Info( userName, password );
return new SecurityToken( info, nonce, created );
}
return DefaultInstance.ReadToken( reader, tokenResolver );
}
示例6: ReadFromXml
public void ReadFromXml(XmlReader reader)
{
reader.MoveToContent();
if (reader.IsEmptyElement) { reader.Read(); return; }
num = int.Parse(reader.GetAttribute("number"));
reader.Read();
while (!reader.EOF)
{
if (reader.IsStartElement())
{
if (reader.Name == "class")
{
var sClass = new ScheduleClass();
sClass.ReadFromXml(reader);
classes.Add(sClass);
}
else
{
reader.Skip();
}
}
else
{
reader.Read();
break;
}
}
}
示例7: DoDeserializeValue
protected override object DoDeserializeValue(XmlReader reader, bool isSimpleValue)
{
reader.ReadStartElement(); // Read start of enclosing element
IFilter result = MediaItemQuery.DeserializeFilter(reader);
reader.ReadEndElement(); // End of enclosing element
return result;
}
示例8: HandleTypeAttribute
protected void HandleTypeAttribute(XmlReader reader)
{
DebugCheck.NotNull(reader);
string type;
if (!Utils.GetString(Schema, reader, out type))
{
return;
}
TypeModifier typeModifier;
Function.RemoveTypeModifier(ref type, out typeModifier, out _isRefType);
switch (typeModifier)
{
case TypeModifier.Array:
_collectionKind = CollectionKind.Bag;
break;
default:
Debug.Assert(
typeModifier == TypeModifier.None,
string.Format(
CultureInfo.CurrentCulture,
"Type is not valid for property {0}: {1}. The modifier for the type cannot be used in this context.", FQName,
reader.Value));
break;
}
if (!Utils.ValidateDottedName(Schema, reader, type))
{
return;
}
_unresolvedType = type;
}
示例9: DeserializePropertyElement
protected override void DeserializePropertyElement(XmlReader reader)
{
if (reader == null) throw new ArgumentNullException ("reader");
if (reader.NamespaceURI == Schemas.UpnpSchema) {
switch (reader.LocalName) {
case "producer":
producer_list.Add (reader.ReadString ());
break;
default:
base.DeserializePropertyElement (reader);
break;
}
} else if (reader.NamespaceURI == Schemas.DublinCoreSchema) {
switch (reader.LocalName) {
case "contributor":
contributor_list.Add (reader.ReadString ());
break;
case "date":
Date = reader.ReadString ();
break;
default:
base.DeserializePropertyElement (reader);
break;
}
} else {
base.DeserializePropertyElement (reader);
}
}
示例10: XmlDecoder
/// <summary>
/// Initializes the object with a XML reader.
/// </summary>
public XmlDecoder(System.Type systemType, XmlReader reader, ServiceMessageContext context)
{
Initialize();
m_reader = reader;
m_context = context;
string ns = null;
string name = null;
if (systemType != null)
{
XmlQualifiedName typeName = EncodeableFactory.GetXmlName(systemType);
ns = typeName.Namespace;
name = typeName.Name;
}
if (ns == null)
{
m_reader.MoveToContent();
ns = m_reader.NamespaceURI;
name = m_reader.Name;
}
int index = name.IndexOf(':');
if (index != -1)
{
name = name.Substring(index + 1);
}
PushNamespace(ns);
BeginField(name, false);
}
示例11: FromXml
public bool FromXml(XmlReader reader)
{
if (reader == null || reader.Name != "Lib")
{
return false;
}
if (reader.Name == "Order" || reader.ReadToDescendant("Order"))
{
Order = reader.ReadElementContentAsInt();
}
if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
{
Id = reader.ReadElementContentAsString();
}
if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
{
Name = reader.ReadElementContentAsString();
}
if (reader.Name == "Text" || reader.ReadToNextSibling("Text"))
{
Text = reader.ReadElementContentAsString();
}
if (reader.Name == "Memo" || reader.ReadToNextSibling("Memo"))
{
Memo = reader.ReadElementContentAsString();
}
return true;
}
示例12: while
void IFlickrParsable.Load(XmlReader reader)
{
if (reader.LocalName != "referrer")
UtilityMethods.CheckParsingException(reader);
while (reader.MoveToNextAttribute())
{
switch (reader.LocalName)
{
case "url":
Url = reader.Value;
break;
case "searchterm":
SearchTerm = reader.Value;
break;
case "views":
Views = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
break;
default:
UtilityMethods.CheckParsingException(reader);
break;
}
}
reader.Skip();
}
示例13: OrnamentsForm
public OrnamentsForm(XmlReader r, PaletteForm paletteForm, IPaletteFormsHostForm acForm, FormStateFunctions fsf)
{
_isLoading = true;
InitializeOrnamentSettingsForm(r, paletteForm, acForm, fsf);
_fsf.SetSettingsAreSaved(this, M.HasError(_allTextBoxes), ConfirmButton, RevertToSavedButton);
_isLoading = false;
}
示例14: PolicyIdReferenceElementReadWrite
/// <summary>
/// Creates a new PolicyIdReference using the XmlReader instance provided.
/// </summary>
/// <param name="reader">The XmlReader positioned at the PolicyIdReference element.</param>
/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
public PolicyIdReferenceElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
: base( XacmlSchema.Policy, schemaVersion )
{
if (reader == null) throw new ArgumentNullException("reader");
if( reader.LocalName == PolicySchema1.PolicyIdReferenceElement.PolicyIdReference &&
ValidateSchema( reader, schemaVersion ) )
{
if( reader.HasAttributes )
{
// Load all the attributes
while( reader.MoveToNextAttribute() )
{
if( reader.LocalName == PolicyReferenceElement.Version )
{
_version = reader.GetAttribute( PolicyReferenceElement.Version );
}
else if( reader.LocalName == PolicyReferenceElement.EarliestVersion )
{
_earliestVersion = reader.GetAttribute( PolicyReferenceElement.EarliestVersion );
}
else if( reader.LocalName == PolicyReferenceElement.LatestVersion )
{
_latestVersion = reader.GetAttribute( PolicyReferenceElement.LatestVersion );
}
}
reader.MoveToElement();
}
_policyIdReference = reader.ReadElementString();
}
else
{
throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
}
}
示例15: ReadXml
public void ReadXml(XmlReader reader)
{
var s = reader.ReadOuterXml();
var x = XDocument.Parse(s);
if (x.Root == null) return;
foreach (var e in x.Root.Elements())
{
var name = e.Name.ToString();
switch (name)
{
case "List":
foreach (var ee in e.Elements())
_list.Add(Util.DeSerialize<OnlineRegPersonModel>(ee.ToString()));
break;
case "History":
foreach (var ee in e.Elements())
_history.Add(ee.Value);
break;
default:
Util.SetPropertyFromText(this, name, e.Value);
break;
}
}
}