本文整理匯總了C#中System.Xml.Linq.XNode.CreateReader方法的典型用法代碼示例。如果您正苦於以下問題:C# XNode.CreateReader方法的具體用法?C# XNode.CreateReader怎麽用?C# XNode.CreateReader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Linq.XNode
的用法示例。
在下文中一共展示了XNode.CreateReader方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RuntimeOrderPipelinesProcessorConfiguration
public RuntimeOrderPipelinesProcessorConfiguration(XNode xml)
{
if (xml == null) throw new ArgumentNullException("xml");
using (var r = xml.CreateReader())
{
base.DeserializeElement(r, false);
}
}
開發者ID:enticify,項目名稱:Enticify.Cs2009.Components,代碼行數:8,代碼來源:RuntimeOrderPipelinesProcessorConfiguration.cs
示例2: Transform
static void Transform(string resourceName, XNode xml, ITaskItem outputFile)
{
var xmlTransform = new XslCompiledTransform();
using (var writer = XmlWriter.Create(outputFile.GetMetadata("FullPath"), new XmlWriterSettings { Indent = true }))
using (var xsltReader = XmlReader.Create(typeof(xunit).Assembly.GetManifestResourceStream("Xunit.Runner.MSBuild." + resourceName)))
using (var xmlReader = xml.CreateReader())
{
xmlTransform.Load(xsltReader);
xmlTransform.Transform(xmlReader, writer);
}
}
示例3: BuildElement
//.........這裏部分代碼省略.........
comm.ToBeOutput = true;
}
//comm.SetProperty("Content", comment); //dont call this method so that the comment is not "formatted"
comm.Content = comment;
return comm;
}
else if (node.NodeType == XmlNodeType.None || node.NodeType == XmlNodeType.Attribute ||
//node.NodeType == XmlNodeType.ProcessingInstruction ||
node.NodeType == XmlNodeType.Entity ||
node.NodeType == XmlNodeType.Document || node.NodeType == XmlNodeType.DocumentFragment ||
node.NodeType == XmlNodeType.DocumentType || node.NodeType == XmlNodeType.Notation ||
node.NodeType == XmlNodeType.Whitespace || node.NodeType == XmlNodeType.EndElement ||
node.NodeType == XmlNodeType.EndEntity || node.NodeType == XmlNodeType.XmlDeclaration
|| node.NodeType == XmlNodeType.SignificantWhitespace)
{
Nothing nothing = new Nothing();
nothing.Document = this;
nothing.Line = lineInfo.LineNumber;
nothing.Column = lineInfo.LinePosition;
return nothing;
}
if (!(node is XElement))
throw new QuicException(string.Format("Unrecognized XML node '{0}'", node),
this.SourcePath, lineInfo.LineNumber, lineInfo.LinePosition);
XElement elementNode = (XElement)node;
Element element = null;
try
{
element = (Element)BuildObject(elementNode.Name.LocalName, elementNode.GetPrefixOfNamespace(elementNode.Name.Namespace));
element.Document = this; //just in case I delete it from BuildObject(...) by mistake
}
catch (TypeLoadException ex)
{
if (this.OutputOptions.AllowUnknownTags)
{
element = new UnknownElement();
element.Document = this;
var prefix = elementNode.GetPrefixOfNamespace(elementNode.Name.Namespace);
((UnknownElement)element).Tag = (string.IsNullOrWhiteSpace(prefix) ? "" : prefix + ":") + elementNode.Name.LocalName;
((UnknownElement)element).IsEmptyTag = elementNode.IsEmpty;
}
else
{
throw new QuicException(ex.Message, this.SourcePath, lineInfo.LineNumber, lineInfo.LinePosition, ex);
}
}
catch (QuicException)
{
throw;
}
catch (Exception ex)
{
throw new QuicException(ex.Message, this.SourcePath, lineInfo.LineNumber, lineInfo.LinePosition, ex);
}
element.Line = lineInfo.LineNumber;
element.Column = lineInfo.LinePosition;
//set its properties
foreach (XAttribute attri in elementNode.Attributes())
{
//try
//{
if (!attri.IsNamespaceDeclaration)
element.SetProperty(attri.Name.LocalName, attri.Value);
//}
//catch (Exception ex)
//{
// var attriLineInfo = (IXmlLineInfo)attri;
// throw new QuicException(ex.Message, this.SourcePath, attriLineInfo.LineNumber, attriLineInfo.LinePosition, ex);
//}
}
//record the element if it has a name
if (element.Name != null)
{
if (namedElements.ContainsKey(element.Name))
throw new QuicException(string.Format("An element with the name '{0}' already exists.", element.Name),
this.SourcePath, element.Line, element.Column);
namedElements.Add(element.Name, element);
}
//child tags
if ((element).IsContainer)
{
foreach (XNode child in elementNode.Nodes())
{
var uiElement = BuildElement(child);
(element).Elements.Add(uiElement);
}
}
else
{
var reader = node.CreateReader();
reader.MoveToContent();
string innerXml = reader.ReadInnerXml();
//((UIElement)element).Content = innerXml;
element.SetProperty("Content", innerXml);
}
return element;
}
示例4: XmlOutput
public XmlOutput(XNode element)
{
navigator = new XPathDocument(element.CreateReader()).CreateNavigator();
manager = new XmlNamespaceManager(navigator.NameTable);
manager.AddNamespace("r", Namespaces.ShopSchema.NamespaceName);
manager.AddNamespace("x", Namespaces.XForms.NamespaceName);
}
示例5: WriteToFile
private void WriteToFile( XNode doc, StreamWriter file )
{
try
{
XmlReader xr = doc.CreateReader( ) ;
Stylesheet.Transform( xr, null, file.BaseStream ) ;
}
catch ( XsltException e )
{
Trace.TraceError( e.Message ) ;
throw ;
}
}
示例6: GetContentToEncrypt
private string GetContentToEncrypt(XNode element)
{
var reader = element.CreateReader();
reader.MoveToContent();
return reader.ReadInnerXml();
}
示例7: ConstantExpression
public ConstantExpression(XNode value)
: this(value, DbType.AnsiStringFixedLength)
{
if (value == null) {
throw new ArgumentNullException(
"value",
"The value passed to a constant XNode expression must not be null");
}
// TODO reader is IDisposable remove that from here
this.Value = new SqlXml(value.CreateReader());
this.DbType = DbType.Xml;
}