本文整理汇总了C#中ITreeAdaptor.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ITreeAdaptor.GetType方法的具体用法?C# ITreeAdaptor.GetType怎么用?C# ITreeAdaptor.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITreeAdaptor
的用法示例。
在下文中一共展示了ITreeAdaptor.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualsCore
protected static bool EqualsCore(object t1, object t2, ITreeAdaptor adaptor)
{
if ((t1 == null) || (t2 == null))
{
return false;
}
if (adaptor.GetType(t1) != adaptor.GetType(t2))
{
return false;
}
if (!adaptor.GetText(t1).Equals(adaptor.GetText(t2)))
{
return false;
}
int childCount = adaptor.GetChildCount(t1);
int num2 = adaptor.GetChildCount(t2);
if (childCount != num2)
{
return false;
}
for (int i = 0; i < childCount; i++)
{
object child = adaptor.GetChild(t1, i);
object obj3 = adaptor.GetChild(t2, i);
if (!EqualsCore(child, obj3, adaptor))
{
return false;
}
}
return true;
}
示例2: InContext
/// <summary>
/// The worker for <see cref="InContext(TreeParser, string)"/>. It's <see langword="static"/> and full of
/// parameters for testing purposes.
/// </summary>
private static bool InContext(
ITreeAdaptor adaptor,
string[] tokenNames,
object t,
string context)
{
if (Regex.IsMatch(context, DotDot))
{
// don't allow "..", must be "..."
throw new ArgumentException("invalid syntax: ..");
}
if (Regex.IsMatch(context, DoubleEtc))
{
// don't allow double "..."
throw new ArgumentException("invalid syntax: ... ...");
}
context = context.Replace("...", " ... "); // ensure spaces around ...
context = context.Trim();
string[] nodes = context.Split(new[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
int ni = nodes.Length - 1;
t = adaptor.GetParent(t);
while (ni >= 0 && t != null)
{
if (nodes[ni].Equals("..."))
{
// walk upwards until we see nodes[ni-1] then continue walking
if (ni == 0)
{
// ... at start is no-op
return true;
}
string goal = nodes[ni - 1];
object ancestor = GetAncestor(adaptor, tokenNames, t, goal);
if (ancestor == null)
return false;
t = ancestor;
ni--;
}
string name = tokenNames[adaptor.GetType(t)];
if (!name.Equals(nodes[ni]))
{
//System.Console.Error.WriteLine("not matched: " + nodes[ni] + " at " + t);
return false;
}
// advance to parent and to previous element in context node list
ni--;
t = adaptor.GetParent(t);
}
if (t == null && ni >= 0)
return false; // at root but more nodes to match
return true;
}
示例3: _Equals
protected static bool _Equals( object t1, object t2, ITreeAdaptor adaptor )
{
// make sure both are non-null
if ( t1 == null || t2 == null )
{
return false;
}
// check roots
if ( adaptor.GetType( t1 ) != adaptor.GetType( t2 ) )
{
return false;
}
if ( !adaptor.GetText( t1 ).Equals( adaptor.GetText( t2 ) ) )
{
return false;
}
// check children
int n1 = adaptor.GetChildCount( t1 );
int n2 = adaptor.GetChildCount( t2 );
if ( n1 != n2 )
{
return false;
}
for ( int i = 0; i < n1; i++ )
{
object child1 = adaptor.GetChild( t1, i );
object child2 = adaptor.GetChild( t2, i );
if ( !_Equals( child1, child2, adaptor ) )
{
return false;
}
}
return true;
}
示例4: GetAncestor
/// <summary>
/// Helper for static <see cref="InContext(ITreeAdaptor, string[], object, string)"/>.
/// </summary>
private static object GetAncestor(ITreeAdaptor adaptor, string[] tokenNames, object t, string goal)
{
while (t != null)
{
string name = tokenNames[adaptor.GetType(t)];
if (name.Equals(goal))
return t;
t = adaptor.GetParent(t);
}
return null;
}