本文整理汇总了C#中ICSharpCode.NRefactory.Ast.Expression类的典型用法代码示例。如果您正苦于以下问题:C# Expression类的具体用法?C# Expression怎么用?C# Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GridValuesProvider
public GridValuesProvider(Expression targetObject, DebugType itemType)
{
this.targetObject = targetObject;
this.itemType = itemType;
this.memberFromNameMap = this.GetItemTypeMembers().MakeDictionary(memberInfo => memberInfo.Name);
}
示例2: GenerateExpression
private string GenerateExpression(Expression expression)
{
var sb = new StringBuilder();
var memberReferenceExpression = expression as MemberReferenceExpression;
while (memberReferenceExpression != null)
{
if (sb.Length != 0)
sb.Insert(0, ".");
sb.Insert(0, memberReferenceExpression.MemberName);
expression = memberReferenceExpression.TargetObject;
memberReferenceExpression = expression as MemberReferenceExpression;
}
var identifierExpression = expression as IdentifierExpression;
if(identifierExpression != null && sb.Length != 0)
{
string path;
if (aliasToName.TryGetValue(identifierExpression.Identifier, out path))
{
sb.Insert(0, path);
}
}
if (sb.Length == 0)
return null;
return sb.ToString();
}
示例3: ProcessQuery
private void ProcessQuery(Expression queryExpressionSelectClause)
{
var objectCreateExpression = QueryParsingUtils.GetAnonymousCreateExpression(queryExpressionSelectClause) as ObjectCreateExpression;
if (objectCreateExpression == null ||
objectCreateExpression.IsAnonymousType == false)
return;
foreach (
var expression in
objectCreateExpression.ObjectInitializer.CreateExpressions.OfType<NamedArgumentExpression>())
{
var generateExpression = GenerateExpression(expression.Expression);
if (generateExpression != null)
QueryParameters.Add(generateExpression);
}
foreach (
var expression in
objectCreateExpression.ObjectInitializer.CreateExpressions.OfType<MemberReferenceExpression>())
{
var generateExpression = GenerateExpression(expression);
if (generateExpression != null)
QueryParameters.Add(generateExpression);
}
}
示例4: Resolve
public ResolveResult Resolve (Expression expression)
{
ResolveResult result = expression.AcceptVisitor (this, null) as ResolveResult;
if (result == null)
result = CreateResult ("");
return result;
}
示例5: add_Variable
public static VariableDeclaration add_Variable(this BlockStatement blockDeclaration, string name, Expression expression, TypeReference typeReference)
{
var variableDeclaration = new VariableDeclaration(name, expression) {TypeReference = typeReference};
var localVariableDeclaration = new LocalVariableDeclaration(variableDeclaration);
blockDeclaration.append(localVariableDeclaration);
return variableDeclaration;
}
示例6: LazyGetChildNodesOfArray
public static IEnumerable<TreeNode> LazyGetChildNodesOfArray(TreeNode parent, Expression expression, ArrayDimensions dimensions)
{
if (dimensions.TotalElementCount == 0)
return new TreeNode[] { new TreeNode(null, "(empty)", null, null, parent, null) };
return new ArrayRangeNode(parent, expression, dimensions, dimensions).ChildNodes;
}
示例7: GetTarget
/// <summary>
/// Gets "a.b" from "a.b.c"
/// </summary>
Expression GetTarget(Expression memberReferenceExpr)
{
if (memberReferenceExpr is MemberReferenceExpression) {
return ((MemberReferenceExpression)memberReferenceExpr).TargetObject;
}
return null;
}
示例8: ProcessQuery
private void ProcessQuery(Expression queryExpressionSelectClause)
{
var objectCreateExpression = queryExpressionSelectClause as ObjectCreateExpression;
if (objectCreateExpression == null ||
objectCreateExpression.IsAnonymousType == false)
return;
// we only want the outer most value
if (queryProcessed)
return;
queryProcessed = true;
foreach (
var expression in
objectCreateExpression.ObjectInitializer.CreateExpressions.OfType<NamedArgumentExpression>())
{
FieldNames.Add(expression.Name);
}
foreach (
var expression in
objectCreateExpression.ObjectInitializer.CreateExpressions.OfType<MemberReferenceExpression>())
{
FieldNames.Add(expression.MemberName);
}
foreach (
var expression in
objectCreateExpression.ObjectInitializer.CreateExpressions.OfType<IdentifierExpression>())
{
FieldNames.Add(expression.Identifier);
}
}
示例9: ResolveType
public IReturnType ResolveType(Expression expression)
{
ResolveResult rr = Resolve(expression);
if (rr != null)
return rr.ResolvedType;
else
return null;
}
示例10: InferredReturnType
internal InferredReturnType(Expression expression, NRefactoryResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
_expression = expression;
_resolver = resolver;
}
示例11: Assign
public static void Assign(this BlockStatement block, Expression left, Expression right)
{
if (left == null)
throw new ArgumentNullException("left");
if (right == null)
throw new ArgumentNullException("right");
AddStatement(block, new AssignmentExpression(left, AssignmentOperatorType.Assign, right));
}
示例12: IListNode
public IListNode(Expression targetObject)
{
this.targetObject = targetObject;
this.Name = "IList";
this.count = Utils.GetIListCount(this.targetObject);
this.ChildNodes = Utils.LazyGetItemsOfIList(this.targetObject);
}
示例13: IsMethodInvocation
private bool IsMethodInvocation(Expression expression)
{
if (expression.Parent is InvocationExpression)
{
InvocationExpression invocation = (InvocationExpression) expression.Parent;
return expression.GetHashCode() == invocation.TargetObject.GetHashCode();
}
return false;
}
示例14: LazyGetMembersOfObject
public static IEnumerable<TreeNode> LazyGetMembersOfObject(Expression expression, MemberInfo[] members)
{
List<TreeNode> nodes = new List<TreeNode>();
foreach(MemberInfo memberInfo in members) {
nodes.Add(new ExpressionNode(ExpressionNode.GetImageForMember((IDebugMemberInfo)memberInfo), memberInfo.Name, expression.AppendMemberReference((IDebugMemberInfo)memberInfo)));
}
nodes.Sort();
return nodes;
}
示例15: ArrayRangeNode
public ArrayRangeNode(Expression arrayTarget, ArrayDimensions bounds, ArrayDimensions originalBounds)
{
this.arrayTarget = arrayTarget;
this.bounds = bounds;
this.originalBounds = originalBounds;
this.Name = GetName();
this.ChildNodes = LazyGetChildren();
}