本文整理汇总了C#中IPluginVisitor类的典型用法代码示例。如果您正苦于以下问题:C# IPluginVisitor类的具体用法?C# IPluginVisitor怎么用?C# IPluginVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPluginVisitor类属于命名空间,在下文中一共展示了IPluginVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadAscii
private static void ReadAscii(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine)
{
int length = 0;
if (reader.MoveToAttribute("length"))
length = ParseInt(reader.Value);
visitor.VisitAscii(name, offset, visible, length, pluginLine);
}
示例2: HandleElement
private static void HandleElement(XmlReader reader, IPluginVisitor visitor)
{
switch (reader.Name)
{
case "comment":
ReadComment(reader, visitor);
break;
default:
HandleValueElement(reader, reader.Name, visitor);
break;
}
}
示例3: HandleTopLevelElement
private static void HandleTopLevelElement(XmlReader reader, IPluginVisitor visitor)
{
if (reader.Name == "revisions" && visitor.EnterRevisions())
{
ReadRevisions(reader.ReadSubtree(), visitor);
visitor.LeaveRevisions();
}
else
{
HandleElement(reader, visitor);
}
}
示例4: LoadPlugin
/// <summary>
/// Parses an XML plugin, calling the corresponding method in
/// IPluginVisitor for each XML tag it encounters.
/// </summary>
/// <param name="reader">The XmlReader to read the plugin XML from.</param>
/// <param name="visitor">The IPluginVisitor to call for each XML tag.</param>
public static void LoadPlugin(XmlReader reader, IPluginVisitor visitor)
{
if (!reader.ReadToNextSibling("plugin"))
throw new ArgumentException("The XML file is missing a <plugin> tag.");
var baseSize = 0;
if (reader.MoveToAttribute("baseSize"))
baseSize = ParseInt(reader.Value);
if (!visitor.EnterPlugin(baseSize)) return;
ReadElements(reader, true, visitor);
visitor.LeavePlugin();
}
示例5: LoadPlugin
/// <summary>
/// Parses an XML plugin, calling the corresponding method in
/// IPluginVisitor for each XML tag it encounters.
/// </summary>
/// <param name="reader">The XmlReader to read the plugin XML from.</param>
/// <param name="visitor">The IPluginVisitor to call for each XML tag.</param>
public static void LoadPlugin(XmlReader reader, IPluginVisitor visitor)
{
if (!reader.ReadToNextSibling("plugin"))
throw new ArgumentException("The XML file is missing a <plugin> tag.");
if (!reader.MoveToAttribute("baseSize"))
throw new ArgumentException("The <plugin> tag is missing the baseSize attribute." + PositionInfo(reader));
int baseSize = ParseInt(reader.Value);
if (visitor.EnterPlugin(baseSize))
{
ReadElements(reader, true, visitor);
visitor.LeavePlugin();
}
}
示例6: LoadPlugin
/// <summary>
/// Parses an XML plugin, calling the corresponding method in
/// IPluginVisitor for each XML tag it encounters.
/// </summary>
/// <param name="reader">The XmlReader to read the plugin XML from.</param>
/// <param name="visitor">The IPluginVisitor to call for each XML tag.</param>
public static void LoadPlugin(XmlReader reader, IPluginVisitor visitor)
{
if (!reader.ReadToNextSibling("plugin"))
throw new ArgumentException("The XML file is missing a <plugin> tag.");
if (!reader.MoveToAttribute("headersize") && !reader.MoveToAttribute("baseSize"))
throw new ArgumentException("The plugin is missing tag size information.");
int baseSize = ParseInt(reader.Value);
if (visitor.EnterPlugin(baseSize))
{
UniversalPluginLoader loader = new UniversalPluginLoader();
loader.ReadElements(reader, true, visitor);
visitor.LeavePlugin();
}
}
示例7: ReadShader
private static void ReadShader(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor,
uint pluginLine)
{
if (!reader.MoveToAttribute("type"))
throw new ArgumentException("Shaders must have a type attribute." + PositionInfo(reader));
ShaderType type;
if (reader.Value == "pixel")
type = ShaderType.Pixel;
else if (reader.Value == "vertex")
type = ShaderType.Vertex;
else
throw new ArgumentException("Invalid shader type \"" + reader.Value + "\"");
visitor.VisitShader(name, offset, visible, type, pluginLine);
}
示例8: ReadElements
private static void ReadElements(XmlReader reader, bool topLevel, IPluginVisitor visitor)
{
while (reader.Read())
{
if (reader.NodeType != XmlNodeType.Element) continue;
if (topLevel)
HandleTopLevelElement(reader, visitor);
else
HandleElement(reader, visitor);
}
}
示例9: ReadComment
private static void ReadComment(XmlReader reader, IPluginVisitor visitor)
{
var title = "Comment";
if (reader.MoveToAttribute("title"))
title = reader.Value;
reader.MoveToElement();
var xmlLineInfo = reader as IXmlLineInfo;
if (xmlLineInfo == null) return;
var pluginLine = (uint)xmlLineInfo.LineNumber;
var text = reader.ReadElementContentAsString();
visitor.VisitComment(title, text, pluginLine);
}
示例10: ReadBits
private static void ReadBits(XmlReader reader, IPluginVisitor visitor)
{
var subtree = reader.ReadSubtree();
subtree.ReadStartElement();
while (subtree.ReadToNextSibling("bit"))
ReadBit(subtree, visitor);
visitor.LeaveBitfield();
}
示例11: DumpRevisions
// Fixes up the version numbers on revisions
private void DumpRevisions(IPluginVisitor visitor)
{
if (visitor.EnterRevisions())
{
// Dump ALL the revisions!
int version = versionBase;
foreach (var pair in revisions)
{
pair.Value.Version = version;
version++;
visitor.VisitRevision(pair.Value);
}
versionBase = version;
visitor.LeaveRevisions();
}
}
示例12: ReadReflexive
private static void ReadReflexive(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine)
{
if (!reader.MoveToAttribute("entrySize"))
throw new ArgumentException("Reflexives must have an entrySize attribute." + PositionInfo(reader));
var entrySize = ParseUInt(reader.Value);
if (visitor.EnterReflexive(name, offset, visible, entrySize, pluginLine))
{
reader.MoveToElement();
var subtree = reader.ReadSubtree();
subtree.ReadStartElement();
ReadElements(subtree, false, visitor);
visitor.LeaveReflexive();
}
else
{
reader.Skip();
}
}
示例13: ReadRange
private static void ReadRange(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine)
{
var min = 0.0;
var max = 0.0;
var largeChange = 0.0;
var smallChange = 0.0;
var type = "int32";
if (reader.MoveToAttribute("min"))
min = double.Parse(reader.Value);
if (reader.MoveToAttribute("max"))
max = double.Parse(reader.Value);
if (reader.MoveToAttribute("smallStep"))
smallChange = double.Parse(reader.Value);
if (reader.MoveToAttribute("largeStep"))
largeChange = double.Parse(reader.Value);
if (reader.MoveToAttribute("type"))
type = reader.Value.ToLower();
visitor.VisitRange(name, offset, visible, type, min, max, smallChange, largeChange, pluginLine);
}
示例14: ReadReflexive
private void ReadReflexive(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor,
uint pluginLine)
{
uint entrySize = 0;
if (reader.MoveToAttribute("entrySize") || reader.MoveToAttribute("size"))
{
if (!string.IsNullOrWhiteSpace(reader.Value))
entrySize = ParseUInt(reader.Value);
}
if (visitor.EnterReflexive(name, offset, visible, entrySize, pluginLine))
{
reader.MoveToElement();
XmlReader subtree = reader.ReadSubtree();
subtree.ReadStartElement();
ReadElements(subtree, false, visitor);
visitor.LeaveReflexive();
}
}
示例15: ReadElements
private void ReadElements(XmlReader reader, bool topLevel, IPluginVisitor visitor)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
string elementName = reader.Name.ToLower();
if (topLevel)
HandleTopLevelElement(reader, elementName, visitor);
else
HandleElement(reader, elementName, visitor);
}
}
}