本文整理汇总了C#中Visitor.Visit方法的典型用法代码示例。如果您正苦于以下问题:C# Visitor.Visit方法的具体用法?C# Visitor.Visit怎么用?C# Visitor.Visit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visitor
的用法示例。
在下文中一共展示了Visitor.Visit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public static QueryComplete Convert(
Expression<Func<BsonDocument, bool>> expression
)
{
var visitor = new Visitor();
visitor.Visit(expression);
return (QueryComplete) visitor.ResultStack.Pop();
}
示例2: Highlight
private JObject Highlight(SyntaxNode root, SemanticModel model)
{
var visitor = new Visitor(model);
visitor.Visit(root);
var regions = visitor.Regions.OrderBy(r => r.Line).ThenBy(r => r.Start)
.GroupBy(r => new
{
Line = r.Line,
Start = r.Start,
End = r.End
}).Select(g =>
{
var k = g.Key;
var c = string.Join(" ", g.Where(r => !string.IsNullOrEmpty(r.Style)).Select(r => r.Style).Distinct());
var props = new JObject(g.Where(r => r.Props != null).SelectMany(r => r.Props.Properties()));
if (props.Count == 0)
props = null;
return new Visitor.Region
{
Start = k.Start,
Line = k.Line,
End = k.End,
Style = c,
Props = props
};
});
JObject lines = new JObject();
foreach (var region in regions)
{
JArray lregions;
var lineProp = lines.Property(region.Line.ToString());
if (lineProp == null)
{
lineProp = new JProperty(region.Line.ToString());
lregions = new JArray();
lineProp.Value = new JObject(new JProperty("ranges", lregions));
lines.Add(lineProp);
}
else
{
lregions = (JArray)((JObject)lineProp.Value).Property("ranges").Value;
}
var annotation = JObject.FromObject(new AnnotationRange(region.Start, region.End, new OrionStyle(styleClass: region.Style, attributes: region.Props)));
if (region.Style.Contains("error"))
AddError((JObject)lineProp.Value, annotation);
lregions.Add(annotation);
}
return lines;
}
示例3: ThrowIfUnsupported
/// <summary>
/// Checks whether the given node is supported on the given server.
/// </summary>
internal static void ThrowIfUnsupported(SqlNode node, SqlNodeAnnotations annotations, SqlProvider.ProviderMode provider) {
// Check to see whether there's at least one SqlServerCompatibilityAnnotation.
if (annotations.HasAnnotationType(typeof(SqlServerCompatibilityAnnotation))) {
Visitor visitor = new Visitor(provider);
visitor.annotations = annotations;
visitor.Visit(node);
// If any messages were recorded, then throw an exception.
if (visitor.reasons.Count > 0) {
throw Error.ExpressionNotSupportedForSqlServerVersion(visitor.reasons);
}
}
}
示例4: Test
private static void Test(Expression exp, Action<Dictionary<Expression, string>> additionalCheck = null)
{
var vis = new Visitor();
vis.Visit(exp);
var sortedPaths = vis.paths.OrderBy(s => s);
sortedPaths.SequenceEqual(vis.paths).Assert();
vis.paths.Skip(1).All(p => Visitor.IsXChildOfY(p, vis.paths[0]) && !Visitor.IsXChildOfY(vis.paths[0], p))
.Assert();
if (additionalCheck != null)
{
additionalCheck(vis.pathsDict);
}
}
示例5: Accept
public override void Accept(Visitor visitor)
{
visitor.Visit(this);
}
示例6: Process
public Expression Process(Expression expression) {
var visitor = new Visitor();
return visitor.Visit(expression);
}
示例7: GenerateNamespaceTypes
protected string GenerateNamespaceTypes(string nameSpace, IList<Type> allTypes)
{
var trace = new StringBuilder();
var visitor = new Visitor();
trace.AppendFormatObject(NamespaceStartFormat, new NameSpaceEventArgs()
{
Comment = nameSpace,
NameSpaceName = nameSpace
});
visitor.TypeVisiting += (sender, args) => {
if (args.BaseTypeInfo != null)
{
trace.AppendFormatObject(DerivedTypeStartFormat, args);
}
else
{
trace.AppendFormatObject(TerminalTypeStartFormat, args);
}
};
visitor.TypeVisited += (sender, args) => { trace.AppendFormatObject(TypeEndFormat, args); };
Func<MemberEventArgs, bool> include = args =>
(this.ExportsNonPublicMembers || args.IsPublic) && args.IsOwnProperty && !args.IgnoredByGenerators.Contains(this.id);
visitor.MemberVisiting += (sender, args) => {
if (include(args))
{
trace.AppendFormatObject(MemberStartFormat, args);
}
};
visitor.MemberVisited += (sender, args) =>
{
if (include(args))
{
trace.AppendFormatObject(MemberEndFormat, args);
}
};
visitor.MethodVisiting += (sender, args) =>
{
if ((this.ExportsNonPublicMembers || args.MethodInfo.IsPublic) && args.IsOwnMethod)
{
trace.AppendFormatObject(MethodStartFormat, args);
}
};
visitor.MethodVisited += (sender, args) =>
{
if ((this.ExportsNonPublicMembers || args.MethodInfo.IsPublic) && args.IsOwnMethod)
{
trace.AppendFormatObject(MethodEndFormat, args);
}
};
visitor.Visit(allTypes, this.language);
trace.AppendFormatObject(NamespaceEndFormat, new NameSpaceEventArgs() { Comment = nameSpace, NameSpaceName = nameSpace });
return trace.ToString().Trim();
}
示例8: CanBigJoin
internal static bool CanBigJoin(SqlSelect select) {
Visitor v = new Visitor();
v.Visit(select);
return v.canBigJoin;
}
示例9: HasHierarchy
internal static bool HasHierarchy(SqlExpression expr) {
Visitor v = new Visitor();
v.Visit(expr);
return v.foundHierarchy;
}
示例10: Accept
public override string Accept(Visitor visitor)
{
return visitor.Visit(this);
}
示例11: ReferencesAny
/// <summary>
/// Returns true iff the given node references any aliases the list of 'aliases'.
/// </summary>
internal static bool ReferencesAny(SqlNode node, IEnumerable<SqlAlias> aliases) {
Visitor visitor = new Visitor();
visitor.aliases = aliases;
visitor.Visit(node);
return visitor.referencesAnyMatchingAliases;
}
示例12: IsDependent
internal static bool IsDependent(SqlNode node, HashSet<SqlAlias> aliasesToCheck, HashSet<SqlExpression> ignoreExpressions) {
Visitor v = new Visitor(aliasesToCheck, ignoreExpressions);
v.Visit(node);
return v.hasDependency;
}
示例13: Gather
internal static HashSet<SqlColumn> Gather(SqlNode node, HashSet<SqlColumn> columns) {
Visitor v = new Visitor(columns);
v.Visit(node);
return columns;
}
示例14: Reduce
internal static SqlNode Reduce(SqlNode node, SqlFactory factory, SqlNodeAnnotations annotations) {
Visitor r = new Visitor(factory, annotations);
return r.Visit(node);
}
示例15: IsSimple
internal static bool IsSimple(SqlExpression expr) {
Visitor v = new Visitor();
v.Visit(expr);
return v.IsSimple;
}