mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace System.Data.Linq.SqlClient
|
|
{
|
|
/// <summary>
|
|
/// Find referenced Aliases within a node.
|
|
/// </summary>
|
|
internal static class SqlAliasesReferenced
|
|
{
|
|
/// <summary>
|
|
/// Private visitor which walks the tree and looks for referenced aliases.
|
|
/// </summary>
|
|
private class Visitor : SqlVisitor {
|
|
internal IEnumerable<SqlAlias> aliases;
|
|
internal bool referencesAnyMatchingAliases = false;
|
|
|
|
internal override SqlNode Visit(SqlNode node) {
|
|
// Short-circuit when the answer is alreading known
|
|
if (this.referencesAnyMatchingAliases) {
|
|
return node;
|
|
}
|
|
return base.Visit(node);
|
|
}
|
|
|
|
internal SqlAlias VisitAliasConsumed(SqlAlias a) {
|
|
if (a == null)
|
|
return a;
|
|
|
|
bool match = false;
|
|
foreach (SqlAlias alias in aliases)
|
|
if (alias == a) {
|
|
match = true;
|
|
break;
|
|
}
|
|
|
|
if (match) {
|
|
this.referencesAnyMatchingAliases = true;
|
|
}
|
|
|
|
return a;
|
|
}
|
|
|
|
internal override SqlExpression VisitColumn(SqlColumn col) {
|
|
VisitAliasConsumed(col.Alias);
|
|
VisitExpression(col.Expression);
|
|
return col;
|
|
}
|
|
|
|
internal override SqlExpression VisitColumnRef(SqlColumnRef cref) {
|
|
VisitAliasConsumed(cref.Column.Alias);
|
|
VisitExpression(cref.Column.Expression);
|
|
return cref;
|
|
}
|
|
}
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
}
|