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


C# BaseReferenceExpression类代码示例

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


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

示例1: Complete

		public override void Complete(CompletionContext context)
		{
			if (declarationBegin > context.StartOffset) {
				base.Complete(context);
				return;
			}
			
			TypeSystemAstBuilder b = new TypeSystemAstBuilder(contextAtCaret);
			b.ShowTypeParameterConstraints = false;
			b.GenerateBody = true;
			
			var entityDeclaration = b.ConvertEntity(this.Entity);
			entityDeclaration.Modifiers &= ~(Modifiers.Virtual | Modifiers.Abstract);
			entityDeclaration.Modifiers |= Modifiers.Override;
			
			if (!this.Entity.IsAbstract) {
				// modify body to call the base method
				if (this.Entity.SymbolKind == SymbolKind.Method) {
					var baseCall = new BaseReferenceExpression().Invoke(this.Entity.Name, ParametersToExpressions(this.Entity));
					var body = entityDeclaration.GetChildByRole(Roles.Body);
					body.Statements.Clear();
					if (((IMethod)this.Entity).ReturnType.IsKnownType(KnownTypeCode.Void))
						body.Statements.Add(new ExpressionStatement(baseCall));
					else
						body.Statements.Add(new ReturnStatement(baseCall));
				} else if (this.Entity.SymbolKind == SymbolKind.Indexer || this.Entity.SymbolKind == SymbolKind.Property) {
					Expression baseCall;
					if (this.Entity.SymbolKind == SymbolKind.Indexer)
						baseCall = new BaseReferenceExpression().Indexer(ParametersToExpressions(this.Entity));
					else
						baseCall = new BaseReferenceExpression().Member(this.Entity.Name);
					var getterBody = entityDeclaration.GetChildByRole(PropertyDeclaration.GetterRole).Body;
					if (!getterBody.IsNull) {
						getterBody.Statements.Clear();
						getterBody.Add(new ReturnStatement(baseCall.Clone()));
					}
					var setterBody = entityDeclaration.GetChildByRole(PropertyDeclaration.SetterRole).Body;
					if (!setterBody.IsNull) {
						setterBody.Statements.Clear();
						setterBody.Add(new AssignmentExpression(baseCall.Clone(), new IdentifierExpression("value")));
					}
				}
			}
			
			var document = context.Editor.Document;
			StringWriter w = new StringWriter();
			var formattingOptions = FormattingOptionsFactory.CreateSharpDevelop();
			var segmentDict = SegmentTrackingOutputFormatter.WriteNode(w, entityDeclaration, formattingOptions, context.Editor.Options);
			
			using (document.OpenUndoGroup()) {
				string newText = w.ToString().TrimEnd();
				document.Replace(declarationBegin, context.EndOffset - declarationBegin, newText);
				var throwStatement = entityDeclaration.Descendants.FirstOrDefault(n => n is ThrowStatement);
				if (throwStatement != null) {
					var segment = segmentDict[throwStatement];
					context.Editor.Select(declarationBegin + segment.Offset, segment.Length);
				}
				CSharpFormatterHelper.Format(context.Editor, declarationBegin, newText.Length, formattingOptions);
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:60,代码来源:OverrideCompletionData.cs

示例2: VisitObjectCreateExpression

		public override object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
		{
			if (objectCreateExpression.Arguments.Count() == 2) {
				Expression obj = objectCreateExpression.Arguments.First();
				Expression func = objectCreateExpression.Arguments.Last();
				Annotation annotation = func.Annotation<Annotation>();
				if (annotation != null) {
					IdentifierExpression methodIdent = (IdentifierExpression)((InvocationExpression)func).Arguments.Single();
					MethodReference method = methodIdent.Annotation<MethodReference>();
					if (method != null) {
						if (HandleAnonymousMethod(objectCreateExpression, obj, method))
							return null;
						// Perform the transformation to "new Action(obj.func)".
						obj.Remove();
						methodIdent.Remove();
						if (!annotation.IsVirtual && obj is ThisReferenceExpression) {
							// maybe it's getting the pointer of a base method?
							if (method.DeclaringType != context.CurrentType) {
								obj = new BaseReferenceExpression();
							}
						}
						if (!annotation.IsVirtual && obj is NullReferenceExpression && !method.HasThis) {
							// We're loading a static method.
							// However it is possible to load extension methods with an instance, so we compare the number of arguments:
							bool isExtensionMethod = false;
							TypeReference delegateType = objectCreateExpression.Type.Annotation<TypeReference>();
							if (delegateType != null) {
								TypeDefinition delegateTypeDef = delegateType.Resolve();
								if (delegateTypeDef != null) {
									MethodDefinition invokeMethod = delegateTypeDef.Methods.FirstOrDefault(m => m.Name == "Invoke");
									if (invokeMethod != null) {
										isExtensionMethod = (invokeMethod.Parameters.Count + 1 == method.Parameters.Count);
									}
								}
							}
							if (!isExtensionMethod) {
								obj = new TypeReferenceExpression { Type = AstBuilder.ConvertType(method.DeclaringType) };
							}
						}
						// now transform the identifier into a member reference
						MemberReferenceExpression mre = new MemberReferenceExpression();
						mre.Target = obj;
						mre.MemberName = methodIdent.Identifier;
						methodIdent.TypeArguments.MoveTo(mre.TypeArguments);
						mre.AddAnnotation(method);
						objectCreateExpression.Arguments.Clear();
						objectCreateExpression.Arguments.Add(mre);
						return null;
					}
				}
			}
			return base.VisitObjectCreateExpression(objectCreateExpression, data);
		}
开发者ID:stgwilli,项目名称:ILSpy,代码行数:53,代码来源:DelegateConstruction.cs

示例3: Visit

 public override object Visit(BaseReferenceExpression baseReferenceExpression, object data)
 {
     //			Console.WriteLine("Visiting base");
     if (resolver.CallingClass == null) {
         return null;
     }
     IClass baseClass = resolver.BaseClass(resolver.CallingClass);
     if (baseClass == null) {
     //				Console.WriteLine("Base Class not found");
         return null;
     }
     //			Console.WriteLine("Base Class: " + baseClass.FullyQualifiedName);
     return new ReturnType(baseClass.FullyQualifiedName);
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:14,代码来源:TypeVisitor.cs

示例4: VisitBaseReferenceExpression

		public sealed override object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) {
			BeginVisit(baseReferenceExpression);
			object result = TrackedVisitBaseReferenceExpression(baseReferenceExpression, data);
			EndVisit(baseReferenceExpression);
			return result;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:6,代码来源:NodeTrackingAstVisitor.cs

示例5: VisitBaseReferenceExpression

		public void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression)
		{
			StartNode(baseReferenceExpression);
			WriteKeyword("base", baseReferenceExpression.Role);
			EndNode(baseReferenceExpression);
		}
开发者ID:x-strong,项目名称:ILSpy,代码行数:6,代码来源:CSharpOutputVisitor.cs

示例6: VisitBaseReferenceExpression

		public virtual void VisitBaseReferenceExpression (BaseReferenceExpression baseReferenceExpression)
		{
			VisitChildren (baseReferenceExpression);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs

示例7: VisitBaseReferenceExpression

		public override void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression)
		{
			UsesNonStaticMember = true;
			base.VisitBaseReferenceExpression(baseReferenceExpression);
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:5,代码来源:StaticVisitor.cs

示例8: TransformCall

        static AstNode TransformCall(bool isVirtual, object operand, MethodDefinition methodDef, List<Ast.Expression> args)
        {
            Cecil.MethodReference cecilMethod = ((MethodReference)operand);
            Ast.Expression target;
            List<Ast.Expression> methodArgs = new List<Ast.Expression>(args);
            if (cecilMethod.HasThis) {
                target = methodArgs[0];
                methodArgs.RemoveAt(0);

                // Unpack any DirectionExpression that is used as target for the call
                // (calling methods on value types implicitly passes the first argument by reference)
                if (target is DirectionExpression) {
                    target = ((DirectionExpression)target).Expression;
                    target.Remove(); // detach from DirectionExpression
                }
            } else {
                target = new TypeReferenceExpression { Type = AstBuilder.ConvertType(cecilMethod.DeclaringType) };
            }
            if (target is ThisReferenceExpression && !isVirtual) {
                // a non-virtual call on "this" might be a "base"-call.
                if (cecilMethod.DeclaringType != methodDef.DeclaringType) {
                    // If we're not calling a method in the current class; we must be calling one in the base class.
                    target = new BaseReferenceExpression();
                }
            }

            // Resolve the method to figure out whether it is an accessor:
            Cecil.MethodDefinition cecilMethodDef = cecilMethod.Resolve();
            if (cecilMethodDef != null) {
                if (cecilMethodDef.IsGetter && methodArgs.Count == 0) {
                    foreach (var prop in cecilMethodDef.DeclaringType.Properties) {
                        if (prop.GetMethod == cecilMethodDef)
                            return target.Member(prop.Name).WithAnnotation(prop);
                    }
                } else if (cecilMethodDef.IsSetter && methodArgs.Count == 1) {
                    foreach (var prop in cecilMethodDef.DeclaringType.Properties) {
                        if (prop.SetMethod == cecilMethodDef)
                            return new Ast.AssignmentExpression(target.Member(prop.Name).WithAnnotation(prop), methodArgs[0]);
                    }
                } else if (cecilMethodDef.IsAddOn && methodArgs.Count == 1) {
                    foreach (var ev in cecilMethodDef.DeclaringType.Events) {
                        if (ev.AddMethod == cecilMethodDef) {
                            return new Ast.AssignmentExpression {
                                Left = target.Member(ev.Name).WithAnnotation(ev),
                                Operator = AssignmentOperatorType.Add,
                                Right = methodArgs[0]
                            };
                        }
                    }
                } else if (cecilMethodDef.IsRemoveOn && methodArgs.Count == 1) {
                    foreach (var ev in cecilMethodDef.DeclaringType.Events) {
                        if (ev.RemoveMethod == cecilMethodDef) {
                            return new Ast.AssignmentExpression {
                                Left = target.Member(ev.Name).WithAnnotation(ev),
                                Operator = AssignmentOperatorType.Subtract,
                                Right = methodArgs[0]
                            };
                        }
                    }
                }
            }
            // Default invocation
            return target.Invoke(cecilMethod.Name, ConvertTypeArguments(cecilMethod), methodArgs).WithAnnotation(cecilMethod);
        }
开发者ID:petr-k,项目名称:ILSpy,代码行数:64,代码来源:AstMethodBodyBuilder.cs

示例9: PrimaryExpr


//.........这里部分代码省略.........
				lexer.NextToken();

#line  1913 "cs.ATG" 
				val = "System.UInt64"; 
				break;
			}
			case 120: {
				lexer.NextToken();

#line  1914 "cs.ATG" 
				val = "System.UInt16"; 
				break;
			}
			case 123: {
				lexer.NextToken();

#line  1915 "cs.ATG" 
				val = "System.Void"; 
				break;
			}
			}

#line  1917 "cs.ATG" 
			pexpr = new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation }; 
		} else if (la.kind == 111) {
			lexer.NextToken();

#line  1920 "cs.ATG" 
			pexpr = new ThisReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 51) {
			lexer.NextToken();

#line  1922 "cs.ATG" 
			pexpr = new BaseReferenceExpression(); pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; 
		} else if (la.kind == 89) {
			NewExpression(
#line  1925 "cs.ATG" 
out pexpr);
		} else if (la.kind == 115) {
			lexer.NextToken();
			Expect(20);
			if (
#line  1929 "cs.ATG" 
NotVoidPointer()) {
				Expect(123);

#line  1929 "cs.ATG" 
				type = new TypeReference("System.Void", true); 
			} else if (StartOf(10)) {
				TypeWithRestriction(
#line  1930 "cs.ATG" 
out type, true, true);
			} else SynErr(208);
			Expect(21);

#line  1932 "cs.ATG" 
			pexpr = new TypeOfExpression(type); 
		} else if (la.kind == 63) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1934 "cs.ATG" 
out type);
			Expect(21);

#line  1934 "cs.ATG" 
开发者ID:mgagne-atman,项目名称:Projects,代码行数:67,代码来源:Parser.cs

示例10: VisitBaseReferenceExpression

		public virtual object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) {
			Debug.Assert((baseReferenceExpression != null));
			return null;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:4,代码来源:AbstractASTVisitor.cs

示例11: VisitBaseReferenceExpression

 public void VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression)
 {
     JsonObject expression = CreateJsonExpression(baseReferenceExpression);
     Push(expression);
 }
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:5,代码来源:AstCsToJson.cs

示例12: VisitBaseReferenceExpression

 public void VisitBaseReferenceExpression(BaseReferenceExpression node)
 {
     VisitChildren(node);
 }
开发者ID:evanw,项目名称:minisharp,代码行数:4,代码来源:Lower.cs

示例13: VisitBaseReferenceExpression

		public virtual object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) {
			throw new global::System.NotImplementedException("BaseReferenceExpression");
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NotImplementedAstVisitor.cs

示例14: PrimaryExpr

        private void PrimaryExpr(out Expression pexpr)
        {
            TypeReference typeReference = null;
            List<TypeReference> types = null;
            Expression expression;
            bool flag = false;
            pexpr = null;
            if (this.la.kind == 0x70)
            {
                base.lexer.NextToken();
                pexpr = new PrimitiveExpression(true, "true");
            }
            else if (this.la.kind == 0x47)
            {
                base.lexer.NextToken();
                pexpr = new PrimitiveExpression(false, "false");
            }
            else if (this.la.kind == 0x59)
            {
                base.lexer.NextToken();
                pexpr = new PrimitiveExpression(null, "null");
            }
            else if (this.la.kind == 2)
            {
                base.lexer.NextToken();
                pexpr = new PrimitiveExpression(this.t.literalValue, this.t.val);
            }
            else if ((this.la.kind == 1) && (this.Peek(1).kind == 10))
            {
                base.Expect(1);
                typeReference = new TypeReference(this.t.val);
                base.Expect(10);
                pexpr = new TypeReferenceExpression(typeReference);
                base.Expect(1);
                if (typeReference.Type == "global")
                {
                    typeReference.IsGlobal = true;
                    typeReference.Type = this.t.val ?? "?";
                }
                else
                {
                    typeReference.Type = typeReference.Type + "." + (this.t.val ?? "?");
                }
            }
            else if (this.la.kind == 1)
            {
                base.lexer.NextToken();
                pexpr = new IdentifierExpression(this.t.val);
            }
            else if (this.la.kind == 20)
            {
                base.lexer.NextToken();
                this.Expr(out expression);
                base.Expect(0x15);
                pexpr = new ParenthesizedExpression(expression);
            }
            else if (!this.StartOf(0x1a))
            {
                if (this.la.kind == 110)
                {
                    base.lexer.NextToken();
                    pexpr = new ThisReferenceExpression();
                }
                else if (this.la.kind == 50)
                {
                    base.lexer.NextToken();
                    Expression targetObject = new BaseReferenceExpression();
                    if (this.la.kind == 15)
                    {
                        base.lexer.NextToken();
                        base.Expect(1);
                        targetObject = new FieldReferenceExpression(targetObject, this.t.val);
                    }
                    else if (this.la.kind == 0x12)
                    {
                        base.lexer.NextToken();
                        this.Expr(out expression);
                        List<Expression> indices = new List<Expression>();
                        if (expression != null)
                        {
                            indices.Add(expression);
                        }
                        while (this.la.kind == 14)
                        {
                            base.lexer.NextToken();
                            this.Expr(out expression);
                            if (expression != null)
                            {
                                indices.Add(expression);
                            }
                        }
                        base.Expect(0x13);
                        targetObject = new IndexerExpression(targetObject, indices);
                    }
                    else
                    {
                        base.SynErr(0xb3);
                    }
                    pexpr = targetObject;
                }
//.........这里部分代码省略.........
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:101,代码来源:Parser.cs

示例15: TrackedVisitBaseReferenceExpression

		public virtual object TrackedVisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) {
			return base.VisitBaseReferenceExpression(baseReferenceExpression, data);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NodeTrackingAstVisitor.cs


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