本文整理汇总了C#中System.Xml.XmlWriter.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.GetType方法的具体用法?C# XmlWriter.GetType怎么用?C# XmlWriter.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlNoNamespaceWriter
private XmlNoNamespaceWriter(XmlWriter xmlWriter)
{
mAttributeStack = new Stack<bool>();
mStripNextString = false;
mXmlWriter = xmlWriter;
mAddNamespace = mXmlWriter.GetType().GetMethod("AddNamespace", BindingFlags.NonPublic | BindingFlags.Instance);
}
示例2: XmlWriteAttributeElement
/// <summary>
/// Writes an XML Element with Attributes using a Dictionary of items.
/// </summary>
/// <param name="writer">Writer that has the assigned file location</param>
/// <param name="tag">Xml Open Tag</param>
/// <param name="attributePool">Dictionary of your attributes ["Key" Being your attirbute name and "Value" being it's value]</param>
/// <param name="descriptionValue">Element Description Value</param>
public void XmlWriteAttributeElement(XmlWriter writer, string tag, Dictionary<string, string> attributePool, string descriptionValue)
{
if (writer != null)
{
writer.WriteStartElement(tag);
foreach (KeyValuePair<string, string> kvp in attributePool)
{
writer.WriteAttributeString(kvp.Key, kvp.Value);
}
writer.WriteString(descriptionValue);
writer.WriteEndElement();
}
else
{
throw new ArgumentNullException(writer.GetType().Name, "Writer is Null, please generate one using XmlWriter.Create().");
}
}
示例3: WriteTo
public override void WriteTo(XmlWriter w)
{
if (positionXmlDocument.oldWriter != w)
{
try
{
positionXmlDocument.oldWriter = w;
positionXmlDocument.lineCnt = 0;
positionXmlDocument.linePositionPrevious = 0;
var xmlWriterField = w.GetType()
.GetField("xmlWriter", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
if (xmlWriterField != null)
{
var xmlwriter = xmlWriterField.GetValue(w);
var rawTextWPrp = xmlwriter.GetType()
.GetProperty("InnerWriter", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
var rawTextW = rawTextWPrp.GetValue(xmlwriter, null);
var bufCharsField = rawTextW.GetType()
.GetField("bufChars", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
var contentPosField = rawTextW.GetType()
.GetField("contentPos", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
var buffPosField = rawTextW.GetType()
.GetField("bufPos", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
var ioTextWriterField = rawTextW.GetType()
.GetField("writer", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
var ioTextWriter = ioTextWriterField.GetValue(rawTextW);
var sbField = ioTextWriter.GetType()
.GetField("_sb", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
positionXmlDocument.writerSb = sbField.GetValue(ioTextWriter) as StringBuilder;
positionXmlDocument.bufGetter =
Expression.Lambda<Func<char[]>>(Expression.Field(Expression.Constant(rawTextW), bufCharsField)).Compile();
positionXmlDocument.contentPosFieldGetter =
Expression.Lambda<Func<int>>(Expression.Field(Expression.Constant(rawTextW), contentPosField)).Compile();
positionXmlDocument.buffPosGetter =
Expression.Lambda<Func<int>>(Expression.Field(Expression.Constant(rawTextW), buffPosField)).Compile();
}
}
catch(Exception)
{ }
}
if (positionXmlDocument.bufGetter != null && positionXmlDocument.buffPosGetter != null &&
positionXmlDocument.writerSb != null)
{
try
{
var buff = positionXmlDocument.bufGetter();
var pos = positionXmlDocument.buffPosGetter();
for (int n = pos; n >= positionXmlDocument.lastCharacterPos; n--)
{
if (buff[n] == '\n')
{
positionXmlDocument.lineCnt++;
}
}
this.xamlElementLineInfo = new XamlElementLineInfo(positionXmlDocument.lineCnt + 1,
pos + 1 + positionXmlDocument.writerSb.Length);
if (buff[pos - 1] != '>')
this.xamlElementLineInfo.LinePosition++;
this.xamlElementLineInfo.Position = pos + positionXmlDocument.writerSb.Length;
}
catch (Exception)
{
}
}
base.WriteTo(w);
if (positionXmlDocument.bufGetter != null && positionXmlDocument.buffPosGetter != null &&
positionXmlDocument.writerSb != null)
{
try
{
var pos = positionXmlDocument.buffPosGetter();
this.xamlElementLineInfo.Length = pos + positionXmlDocument.writerSb.Length - this.xamlElementLineInfo.Position;
}
catch (Exception)
{
}
}
}