当前位置: 首页>>代码示例>>C#>>正文


C# Ast.MemberReferenceExpression类代码示例

本文整理汇总了C#中ICSharpCode.NRefactory.Ast.MemberReferenceExpression的典型用法代码示例。如果您正苦于以下问题:C# MemberReferenceExpression类的具体用法?C# MemberReferenceExpression怎么用?C# MemberReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MemberReferenceExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了MemberReferenceExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: add_Invocation

        //, AstExpression expression)
        public static InvocationExpression add_Invocation(this BlockStatement blockStatement, string typeName, string methodName, params object[] parameters)
        {
            if (methodName.valid().isFalse())
                return null;

            Expression memberExpression = null;
            if (typeName.valid())
                memberExpression = new MemberReferenceExpression(new IdentifierExpression(typeName), methodName);
            else
                memberExpression = new IdentifierExpression(methodName);

            var memberReference = new InvocationExpression(memberExpression);
            if (parameters != null)
            {
                var arguments = new List<Expression>();
                foreach (var parameter in parameters)
                    if (parameter is Expression)
                        arguments.add(parameter as Expression);
                    else
                        arguments.add(new PrimitiveExpression(parameter, parameter.str()));

                memberReference.Arguments = arguments;
            }

            blockStatement.append(memberReference.expressionStatement());

            return memberReference;
        }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:29,代码来源:InvocationExpression_ExtensionMethods.cs

示例2: GenerateCode

		public override void GenerateCode(List<AbstractNode> nodes, IList items)
		{
			TypeReference stringReference = new TypeReference("System.String", true);
			MethodDeclaration method = new MethodDeclaration {
				Name = "ToString",
				Modifier = Modifiers.Public | Modifiers.Override,
				TypeReference = stringReference,
			};
			method.Body = new BlockStatement();
			Expression target = new MemberReferenceExpression(new TypeReferenceExpression(stringReference),
			                                                  "Format");
			InvocationExpression methodCall = new InvocationExpression(target);
			StringBuilder formatString = new StringBuilder();
			formatString.Append('[');
			formatString.Append(currentClass.Name);
			for (int i = 0; i < items.Count; i++) {
				formatString.Append(' ');
				formatString.Append(codeGen.GetPropertyName(((FieldWrapper)items[i]).Field.Name));
				formatString.Append("={");
				formatString.Append(i);
				formatString.Append('}');
			}
			formatString.Append(']');
			methodCall.Arguments.Add(new PrimitiveExpression(formatString.ToString(), formatString.ToString()));
			foreach (FieldWrapper w in items) {
				methodCall.Arguments.Add(new MemberReferenceExpression(new ThisReferenceExpression(), w.Field.Name));
			}
			method.Body.AddChild(new ReturnStatement(methodCall));
			nodes.Add(method);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:30,代码来源:ToStringCodeGenerator.cs

示例3: add_MemberReference

 //, AstExpression expression)
 public static MemberReferenceExpression add_MemberReference(this BlockStatement blockStatement, string memberName, string className)
 {
     var identifier = new IdentifierExpression(memberName);
     var memberReference = new MemberReferenceExpression(identifier, className);
     blockStatement.append(memberReference.expressionStatement());
     return memberReference;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:8,代码来源:MemberReferenceExpression_ExtensionMethods.cs

示例4: VisitTypeDeclaration

		public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
		{
			base.VisitTypeDeclaration(typeDeclaration, data); // visit methods
			typeDeclaration.Attributes.Clear();
			typeDeclaration.BaseTypes.Clear();
			
			// add constructor accepting the wrapped object and the field holding the object
			FieldDeclaration fd = new FieldDeclaration(null, // no attributes
			                                           new TypeReference(typeDeclaration.Name),
			                                           Modifiers.Private);
			fd.Fields.Add(new VariableDeclaration("wrappedObject"));
			typeDeclaration.AddChild(fd);
			
			typeDeclaration.Name += "Wrapper";
			if (typeDeclaration.Type == ClassType.Interface) {
				typeDeclaration.Type = ClassType.Class;
				typeDeclaration.Name = typeDeclaration.Name.Substring(1);
			}
			ConstructorDeclaration cd = new ConstructorDeclaration(typeDeclaration.Name,
			                                                       Modifiers.Public,
			                                                       new List<ParameterDeclarationExpression>(),
			                                                       null);
			cd.Parameters.Add(new ParameterDeclarationExpression(fd.TypeReference,
			                                                     "wrappedObject"));
			// this.wrappedObject = wrappedObject;
			Expression fieldReference = new MemberReferenceExpression(new ThisReferenceExpression(),
			                                                         "wrappedObject");
			Expression assignment = new AssignmentExpression(fieldReference,
			                                                 AssignmentOperatorType.Assign,
			                                                 new IdentifierExpression("wrappedObject"));
			cd.Body = new BlockStatement();
			cd.Body.AddChild(new ExpressionStatement(assignment));
			typeDeclaration.AddChild(cd);
			
			for (int i = 0; i < typeDeclaration.Children.Count; i++) {
				object child = typeDeclaration.Children[i];
				if (child is MethodDeclaration) {
					MethodDeclaration method = (MethodDeclaration)child;
					if (method.Parameters.Count == 0 &&
					    (method.Name.StartsWith("Is") || method.Name.StartsWith("Get")))
					{
						// replace the method with a property
						PropertyDeclaration prop = new PropertyDeclaration(method.Modifier,
						                                                   method.Attributes,
						                                                   method.Name,
						                                                   null);
						prop.TypeReference = method.TypeReference;
						prop.GetRegion = new PropertyGetRegion(method.Body, null);
						typeDeclaration.Children[i] = prop;
					}
				}
			}
			
			return null;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:55,代码来源:WrapperGeneratorVisitor.cs

示例5: MethodOnThisReferenceInvocation

		public void MethodOnThisReferenceInvocation()
		{
			// InitializeComponents();
			MemberReferenceExpression field = new MemberReferenceExpression(new ThisReferenceExpression(), "InitializeComponents");
			InvocationExpression invocation = new InvocationExpression(field, new List<Expression>());
			object output = invocation.AcceptVisitor(new CodeDomVisitor(), null);
			Assert.IsTrue(output is CodeMethodInvokeExpression);
			CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output;
			Assert.AreEqual("InitializeComponents", mie.Method.MethodName);
			Assert.IsTrue(mie.Method.TargetObject is CodeThisReferenceExpression);
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:11,代码来源:InvocationExpressionTest.cs

示例6: VisitMemberReferenceExpression

            public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
            {
                if (memberReferenceExpression.TargetObject is IdentifierExpression)
                {
                    var identifier = (IdentifierExpression) memberReferenceExpression.TargetObject;

                    if (identifier.Identifier == "array" && memberReferenceExpression.MemberName == "Length")
                        UnlockWith(memberReferenceExpression);

                }
                return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
            }
开发者ID:timdams,项目名称:strokes,代码行数:12,代码来源:ArrayLengthPropertyAchievement.cs

示例7: InvocationOfStaticMethod

		public void InvocationOfStaticMethod()
		{
			// System.Drawing.Color.FromArgb();
			MemberReferenceExpression field = new MemberReferenceExpression(new IdentifierExpression("System"), "Drawing");
			field = new MemberReferenceExpression(field, "Color");
			field = new MemberReferenceExpression(field, "FromArgb");
			InvocationExpression invocation = new InvocationExpression(field, new List<Expression>());
			object output = invocation.AcceptVisitor(new CodeDomVisitor(), null);
			Assert.IsTrue(output is CodeMethodInvokeExpression);
			CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output;
			Assert.AreEqual("FromArgb", mie.Method.MethodName);
			Assert.IsTrue(mie.Method.TargetObject is CodeTypeReferenceExpression);
			Assert.AreEqual("System.Drawing.Color", (mie.Method.TargetObject as CodeTypeReferenceExpression).Type.BaseType);
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:14,代码来源:InvocationExpressionTest.cs

示例8: ModifyLambdaForSelect

		private static INode ModifyLambdaForSelect(ParenthesizedExpression parenthesizedlambdaExpression,
		                                           MemberReferenceExpression target)
		{
			var parentInvocation = target.TargetObject as InvocationExpression;
			if(parentInvocation != null)
			{
				var parentTarget = parentInvocation.TargetObject as MemberReferenceExpression;
				if(parentTarget != null && parentTarget.MemberName == "GroupBy")
				{
					return new CastExpression(new TypeReference("Func<IGrouping<dynamic,dynamic>, dynamic>"), parenthesizedlambdaExpression, CastType.Cast);
				}
			}
			return new CastExpression(new TypeReference("Func<dynamic, dynamic>"), parenthesizedlambdaExpression, CastType.Cast);
		}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:14,代码来源:TransformDynamicLambdaExpressions.cs

示例9: VisitMemberReferenceExpression

		public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
		{
			foreach (var forbidden in Members.Where(x => x.Names.Contains(memberReferenceExpression.MemberName)))
			{
				var identifierExpression = GetTarget(memberReferenceExpression);
				if(forbidden.TypeAliases.Contains(identifierExpression) == false)
					continue;

				var text = QueryParsingUtils.ToText(memberReferenceExpression);
				throw new InvalidOperationException(string.Format(forbidden.Error, text));
			}

			return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
		}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:14,代码来源:ThrowOnInvalidMethodCalls.cs

示例10: VisitMemberReferenceExpression

        public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
        {
            var identifierExpression = memberReferenceExpression.TargetObject as IdentifierExpression;
            if (identifierExpression == null || identifierExpression.Identifier != identifier)
                return base.VisitMemberReferenceExpression(memberReferenceExpression, data);

            var indexerExpression = new IndexerExpression(
                memberReferenceExpression.TargetObject,
                new List<Expression> { new PrimitiveExpression(memberReferenceExpression.MemberName, memberReferenceExpression.MemberName) });

            ReplaceCurrentNode(indexerExpression);
            indexerExpression.Parent = memberReferenceExpression.Parent;

            return indexerExpression;
        }
开发者ID:sirrocco,项目名称:rhino-divandb,代码行数:15,代码来源:TransformVisitor.cs

示例11: GenerateCode

		public override void GenerateCode(List<AbstractNode> nodes, IList items)
		{
			ConstructorDeclaration ctor = new ConstructorDeclaration(currentClass.Name, Modifiers.Public, null, null);
			ctor.Body = new BlockStatement();
			foreach (FieldWrapper w in items) {
				string parameterName = codeGen.GetParameterName(w.Field.Name);
				ctor.Parameters.Add(new ParameterDeclarationExpression(ConvertType(w.Field.ReturnType),
				                                                       parameterName));
				Expression left  = new MemberReferenceExpression(new ThisReferenceExpression(), w.Field.Name);
				Expression right = new IdentifierExpression(parameterName);
				Expression expr  = new AssignmentExpression(left, AssignmentOperatorType.Assign, right);
				ctor.Body.AddChild(new ExpressionStatement(expr));
			}
			nodes.Add(ctor);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:15,代码来源:ConstructorCodeGenerator.cs

示例12: VisitMemberReferenceExpression

            public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
            {
                if (memberReferenceExpression.MemberName == "Abort")
                {
                    if (memberReferenceExpression.TargetObject is IdentifierExpression)
                    {
                        var id = (IdentifierExpression)memberReferenceExpression.TargetObject;
                        if (threadVars.Contains(id.Identifier))
                        {
                            UnlockWith(memberReferenceExpression);
                        }
                    }
                }

                return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
            }
开发者ID:timdams,项目名称:strokes,代码行数:16,代码来源:ThreadMethodschievements.cs

示例13: VisitMemberReferenceExpression

		public override object VisitMemberReferenceExpression(MemberReferenceExpression fieldReferenceExpression, object data)
		{
			ResolveResult fieldRR = base.VisitMemberReferenceExpression(fieldReferenceExpression, data) as ResolveResult;
			
			if (vbMyFormsClass != null && IsReferenceToInstanceMember(fieldRR)) {
				TypeResolveResult trr = Resolve(fieldReferenceExpression.TargetObject) as TypeResolveResult;
				if (trr != null && trr.ResolvedClass != null) {
					foreach (IProperty p in vbMyFormsClass.Properties) {
						if (p.ReturnType.FullyQualifiedName == trr.ResolvedClass.FullyQualifiedName) {
							fieldReferenceExpression.TargetObject = MakeFieldReferenceExpression("My.MyProject.Forms." + p.Name);
						}
					}
				}
			}
			
			return null;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:17,代码来源:VBNetToCSharpConvertVisitorWithMyFormsSupport.cs

示例14: VisitMemberReferenceExpression

 public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
 {
     IdentifierExpression id = memberReferenceExpression.TargetObject as IdentifierExpression;
     if (id != null) {
         if (id.Identifier == "System" || id.Identifier == currentClass) {
             ReplaceCurrentNode(new IdentifierExpression(memberReferenceExpression.MemberName));
             return null;
         }
         if (id.Identifier.StartsWith("System.")) {
             id.Identifier = id.Identifier.Replace("System.", "");
             return null;
         }
     }
     // we can't always remove "this", the field name might conflict with a parameter/local variable
     //			if (memberReferenceExpression.TargetObject is ThisReferenceExpression) {
     //				ReplaceCurrentNode(new IdentifierExpression(memberReferenceExpression.MemberName));
     //				return null;
     //			}
     return base.VisitMemberReferenceExpression(memberReferenceExpression, data);
 }
开发者ID:almazik,项目名称:ILSpy,代码行数:20,代码来源:SimplifyTypeReferences.cs

示例15: SimpleNonInvocationExpression


//.........这里部分代码省略.........

#line  1676 "VBNET.ATG" 
				pexpr = new TypeReferenceExpression(new TypeReference(val, true)); 
				break;
			}
			case 139: {
				lexer.NextToken();

#line  1677 "VBNET.ATG" 
				pexpr = new ThisReferenceExpression(); 
				break;
			}
			case 144: case 145: {

#line  1678 "VBNET.ATG" 
				Expression retExpr = null; 
				if (la.kind == 144) {
					lexer.NextToken();

#line  1679 "VBNET.ATG" 
					retExpr = new BaseReferenceExpression(); 
				} else if (la.kind == 145) {
					lexer.NextToken();

#line  1680 "VBNET.ATG" 
					retExpr = new ClassReferenceExpression(); 
				} else SynErr(258);
				Expect(16);
				IdentifierOrKeyword(
#line  1682 "VBNET.ATG" 
out name);

#line  1682 "VBNET.ATG" 
				pexpr = new MemberReferenceExpression(retExpr, name); 
				break;
			}
			case 117: {
				lexer.NextToken();
				Expect(16);
				Identifier();

#line  1684 "VBNET.ATG" 
				type = new TypeReference(t.val ?? ""); 

#line  1686 "VBNET.ATG" 
				type.IsGlobal = true; 

#line  1687 "VBNET.ATG" 
				pexpr = new TypeReferenceExpression(type); 
				break;
			}
			case 148: {
				ObjectCreateExpression(
#line  1688 "VBNET.ATG" 
out expr);

#line  1688 "VBNET.ATG" 
				pexpr = expr; 
				break;
			}
			case 81: case 93: case 204: {

#line  1690 "VBNET.ATG" 
				CastType castType = CastType.Cast; 
				if (la.kind == 93) {
					lexer.NextToken();
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:67,代码来源:Parser.cs


注:本文中的ICSharpCode.NRefactory.Ast.MemberReferenceExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。