本文整理汇总了C#中INode.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# INode.GetType方法的具体用法?C# INode.GetType怎么用?C# INode.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchNode
private void FetchNode(System.Windows.Forms.TreeNode treeNode, INode gameNode)
{
string name = (gameNode.Name == "Undefined") ? "" : " : " + gameNode.Name;
if ((gameNode is GameEntity))
{
name += " " + (gameNode as GameEntity).Position;
}
if (gameNode is Sprite)
{
name += (gameNode as Sprite).Origin;
}
System.Windows.Forms.TreeNode node = new System.Windows.Forms.TreeNode(gameNode.GetType().Name + name);
if ((gameNode is Entity && (gameNode as Entity).IsLoaded))
{
PropertyInfo[] properties = gameNode.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
System.Windows.Forms.TreeNode propertiesNode = new System.Windows.Forms.TreeNode("Properties");
foreach (PropertyInfo p in properties)
{
object value = null;
try
{
value = p.GetValue(gameNode, null);
}
catch (Exception e)
{
}
if (value == null) value = "Error";
propertiesNode.Nodes.Add(p.Name + ": " + value);
}
//node.Nodes.Add(propertiesNode);
}
if (gameNode is MilkShakeFramework.Core.TreeNode)
{
MilkShakeFramework.Core.TreeNode gameTreeNode = gameNode as MilkShakeFramework.Core.TreeNode;
foreach (INode childNode in gameTreeNode.Nodes)
{
FetchNode(node, childNode);
}
}
treeNode.Nodes.Add(node);
}
示例2: Visit
public virtual object Visit(INode node, object data)
{
Console.WriteLine("Warning, INode visited!");
Console.WriteLine("Type is " + node.GetType());
Console.WriteLine("Visitor is " + this.GetType());
return node.AcceptChildren(this, data);
}
示例3: Normalise
static INode Normalise(INode node)
{
Type nodeType = node.GetType();
if(nodeType.IsAssignableFrom(typeof(Not))) {
Not notNode = node as Not;
Type childType = notNode.child.GetType();
//Double Negation
if(childType.IsAssignableFrom(typeof(Not))) {
return Normalise((notNode.child as Not).child);
//Not and -> or not
} else if(childType.IsAssignableFrom(typeof(And))) {
And childAnd = notNode.child as And;
return Normalise(new Or(new Not(childAnd.lChild), new Not(childAnd.rChild)));
//Not or -> and not
} else if(childType.IsAssignableFrom(typeof(Or))) {
Or childOr = notNode.child as Or;
return Normalise(new And(new Not(childOr.lChild), new Not(childOr.rChild)));
//Not atom with property -> atom with not property
} else {
Atom childAtom = notNode.child as Atom;
return childAtom.Negate();
}
} else if(nodeType.IsAssignableFrom(typeof(And))) {
And andNode = node as And;
return new And(Normalise(andNode.lChild), Normalise(andNode.rChild));
} else if(nodeType.IsAssignableFrom(typeof(Or))) {
Or orNode = node as Or;
return new Or(Normalise(orNode.lChild), Normalise(orNode.rChild));
} else {
return node;
}
}
示例4: AddNode
public override INode AddNode(INode currentParent, IConverter converter)
{
//If the current parent is neither the root nor a group
if(!(currentParent is IMotherNode))
throw new ArgumentException("Trying to insert an 'AS' node, but the current node's type '" + currentParent.GetType() + "' is illegal. " + CheckString);
GroupNode group;
//If the current parent is the root
if (currentParent is RootNode)
{
group = (currentParent as IMotherNode).Children.Last() as GroupNode;
if (group == null)
throw new ArgumentException("Trying to insert an 'AS' node, but no Group found at root nor in its children. " + CheckString);
}
// The current parent is the group
else if (currentParent is GroupNode)
group = currentParent as GroupNode;
// The group is the last child of the current parent
else if ((currentParent as IMotherNode).Children.Last() is GroupNode)
group = (currentParent as IMotherNode).Children.Last() as GroupNode;
else
throw new ArgumentException("Trying to insert an 'AS' node, but the current node is neither a group nor contains a group as children. " + CheckString);
if (converter != null && converter.Function != null && converter.Function.Arguments != null && converter.Function.Arguments.Any())
group.Name = converter.Function.Arguments[0].ToString();
return currentParent;
}
示例5: Format
public XElement Format(INode contentNode, IEnumerable<INode> features)
{
var featureItemNode = contentNode as FeatureNode;
if (featureItemNode != null)
{
var formattedContent = this.htmlFeatureFormatter.Format(featureItemNode.Feature);
this.htmlImageRelocator.Relocate(contentNode, formattedContent);
return formattedContent;
}
var indexItemNode = contentNode as FolderNode;
if (indexItemNode != null)
{
return this.htmlIndexFormatter.Format(indexItemNode, features);
}
var markdownItemNode = contentNode as MarkdownNode;
if (markdownItemNode != null)
{
this.htmlImageRelocator.Relocate(contentNode, markdownItemNode.MarkdownContent);
return markdownItemNode.MarkdownContent;
}
throw new InvalidOperationException("Cannot format a FeatureNode with a Type of " + contentNode.GetType() +
" as content");
}
示例6: IsEqualTo
public override bool IsEqualTo(INode obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((SelectionSet) obj);
}
示例7: IsEqualTo
public override bool IsEqualTo(INode node)
{
if (ReferenceEquals(null, node)) return false;
if (ReferenceEquals(this, node)) return true;
if (node.GetType() != this.GetType()) return false;
return Equals((Operation) node);
}
示例8: IsEqualTo
public override bool IsEqualTo(INode obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((FragmentDefinition) obj);
}
示例9: IsEqualTo
public override bool IsEqualTo(INode obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((DateTimeValue)obj);
}
示例10: Accept
/// <summary> Accept nodes that are a ATag and have a URL
/// that matches the regex pattern supplied in the constructor.
/// </summary>
/// <param name="node">The node to check.
/// </param>
/// <returns> <code>true</code> if the node is a link with the pattern.
/// </returns>
public virtual bool Accept(INode node)
{
bool ret;
ret = false;
if (typeof(ATag).IsAssignableFrom(node.GetType()))
{
System.String link = ((ATag) node).Link;
CreateMatcher();
return m_obRegex.IsMatch(link);
}
return (ret);
}
示例11: Process
private void Process(TreeNodeCollection treeNodeCollection, INode node)
{
string text = node.GetType().Name;
switch (node.NodeType)
{
case NodeType.Text:
text = node.NodeType.ToString();
break;
default:
break;
}
if (typeof(NDjango.ParserNodes.ErrorNode).IsAssignableFrom(node.GetType()))
text = "ErrorNode";
text += ": " + templateSource.Text.Substring(node.Position, node.Length);
TreeNode tnode = new TreeNode(text);
tnode.Tag = node;
tnode.NodeFont = new Font(templateTree.Font, FontStyle.Underline);
if (node.ErrorMessage.Severity > -1)
tnode.Nodes.Add("(Error)" + node.ErrorMessage.Message);
string vlist = "";
var completion_provider = node as ICompletionProvider;
//if (completion_provider != null)
// foreach (string s in completion_provider.Values)
// vlist += s + ' ';
if (!string.IsNullOrEmpty(vlist))
tnode.Nodes.Add("(Values) = " + vlist);
foreach (KeyValuePair<string, IEnumerable<INode>> item in node.Nodes)
{
TreeNode list = new TreeNode(item.Key);
tnode.Nodes.Add(list);
foreach (INode child in item.Value)
Process(list.Nodes, child);
}
treeNodeCollection.Add(tnode);
}
示例12: Arc
/// <summary>
/// Initializes a new instance of the Arc class with the specified source, target and id.
/// </summary>
/// <param name="source">The source node of the new Arc.</param>
/// <param name="target">The target node of the new Arc.</param>
/// <param name="id">The id of the new Arc.</param>
internal Arc(INode source, INode target, String id)
{
if (source == null)
throw new ArgumentNullException("source");
if (target == null)
throw new ArgumentNullException("target");
if (id == null)
throw new ArgumentNullException("id");
if (source.GetType() == target.GetType())
throw new InvalidOperationException("Invalid arc between nodes of same type!");
_source = source;
_target = target;
_id = id;
}
示例13: Serialize
public void Serialize(string rootPath, INode node, bool recursive = false)
{
string nodePath = Path.Combine(rootPath, node.Name.SanitizeUrl());
if (!_fileSystem.DirectoryExists(nodePath))
_fileSystem.CreateDirectory(nodePath);
var metaModel = new MetaModel(node, nodePath);
using (var fs = _fileSystem.Open(Path.Combine(nodePath, "Properties.txt"), FileMode.Create, FileAccess.Write, FileShare.None))
using (var writer = new StreamWriter(fs))
{
writer.WriteLine("Type: {0}", node.GetType().FullName);
writer.WriteLine("Urls: {0}", node.Uri);
writer.WriteLine("Template: {0}", node.Template);
writer.WriteLine("Publish: {0}", "Never");
writer.WriteLine("Unpublish: {0}", "Never");
}
foreach (var s in metaModel.Properties)
{
string path = Path.Combine(nodePath, s.Name.SanitizeUrl() + ".txt");
using (var fs = _fileSystem.Open(path, FileMode.Create, FileAccess.Write, FileShare.None))
using (var writer = new StreamWriter(fs))
{
writer.Write(s.Value.ToString());
}
}
foreach (var prop in metaModel.XmlProperties)
{
string path = Path.Combine(nodePath, prop.Name.SanitizeUrl() + ".xml");
using (var fs = _fileSystem.Open(path, FileMode.Create, FileAccess.Write, FileShare.None))
using (var writer = new StreamWriter(fs))
{
writer.Write(prop.Value.ToString());
}
}
// TODO
//foreach (var collection in collections.Where(c => !ExcludedProperties.Contains(c.Name)))
//{
//}
if (recursive)
foreach (var child in node.Children)
Serialize(rootPath: nodePath, node: child, recursive: true);
}
示例14: FlattenNode
public StringBuilder FlattenNode(StringBuilder builder, INode node, string parentName, IList<string> names)
{
if (node == null) return builder;
var nodeVariable = node.Name.ToLower().Replace(" ", "").Replace("(", "").Replace(")","").Replace(",","");
if (!names.Contains(nodeVariable))
{
builder.AppendFormat("var {0} = graph.newNode({{label: '{1}', nodeType: '{2}'}});", nodeVariable, node.Name, node.GetType().Name);
names.Add(nodeVariable);
if (parentName != null)
builder.AppendFormat("graph.newEdge({0}, {1}, {{color: '{2}'}});", parentName, nodeVariable, RandomPastelColorGenerator.Instance.GetNextBrush().Color.ToString());
}
if (node.NextNodes != null)
foreach (var subnode in node.NextNodes)
{
FlattenNode(builder, subnode, nodeVariable, names);
}
return builder;
}
示例15: Accept
/// <summary> Accept nodes that are a LinkTag and
/// have a URL that matches the pattern supplied in the constructor.
/// </summary>
/// <param name="node">The node to check.
/// </param>
/// <returns> <code>true</code> if the node is a link with the pattern.
/// </returns>
public virtual bool Accept(INode node)
{
bool ret;
ret = false;
if (typeof(LinkTag).IsAssignableFrom(node.GetType()))
{
System.String link = ((LinkTag) node).Link;
if (mCaseSensitive)
{
if (link.IndexOf(mPattern) > - 1)
ret = true;
}
else
{
if (link.ToUpper().IndexOf(mPattern.ToUpper()) > - 1)
ret = true;
}
}
return (ret);
}