public ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
		{
			if (!(node.MethodExpression is MethodReferenceExpression))
			{
				return null;
			}

			MethodReferenceExpression methodReferenceExpression = node.MethodExpression;

			MethodReference methodReference = methodReferenceExpression.Method;

			if (methodReference.Name == null)
			{
				return null;
			}

			string eventMethodPrefix = GetEventMethodPrefix(methodReference.Name);
			if (string.IsNullOrEmpty(eventMethodPrefix))
			{
				return null;
			}

			if (methodReference.Parameters.Count != 1)
			{
				return null;
			}

            TypeReference typeReference = methodReference.DeclaringType;
			EventDefinition targetEvent = null;
			do
			{
				if (typeReference == null)
				{
					break;
				}

				TypeDefinition typeDefinition = typeReference.Resolve();

				if (typeDefinition == null)
				{
					break;
				}

				string eventName = methodReference.Name.Substring(eventMethodPrefix.Length);
				targetEvent = typeDefinition.Events.FirstOrDefault(e => e.Name == eventName);
				if (targetEvent == null)
				{
					typeReference = typeDefinition.BaseType;
				}
			} while (typeReference != null && targetEvent == null);

			if (targetEvent == null)
			{
				return null;
			}

			EventReferenceExpression target = new EventReferenceExpression(methodReferenceExpression.Target, targetEvent, null);
			return GetEventAssignExpression(target, node.Arguments[0], eventMethodPrefix, node.InvocationInstructions);
		}
        public override Expression CloneExpressionOnly()
        {
            Expression targetClone = Target != null?Target.CloneExpressionOnly() : null;

            EventReferenceExpression result = new EventReferenceExpression(targetClone, Event, null);

            return(result);
        }
        public override Expression Clone()
        {
            Expression targetClone = Target != null?Target.Clone() : null;

            EventReferenceExpression result = new EventReferenceExpression(targetClone, Event, instructions);

            return(result);
        }
        public override bool Equals(Expression other)
        {
            if (!(other is EventReferenceExpression))
            {
                return(false);
            }
            EventReferenceExpression eventRef = other as EventReferenceExpression;

            if (this.Target == null)
            {
                if (eventRef.Target != null)
                {
                    return(false);
                }
            }
            else if (!this.Target.Equals(eventRef.Target))
            {
                return(false);
            }
            return(this.Event.FullName == eventRef.Event.FullName);
        }
		public override void VisitEventReferenceExpression(EventReferenceExpression node)
		{
			if (node.Target != null)
			{
				bool isComplexTarget = IsComplexTarget(node.Target);
				if (isComplexTarget)
				{
					WriteToken("(");
				}
				Visit(node.Target);
				if (isComplexTarget)
				{
					WriteToken(")");
				}
			}
			else
			{
				WriteReferenceAndNamespaceIfInCollision(node.Event.DeclaringType);
			}

			WriteToken(".");
			WriteReference(node.Event.Name, node.Event);
		}
		private Expression GetEventAssignExpression(EventReferenceExpression target, Expression argument, string eventMethodPrefix, IEnumerable<Instruction> instructions)
		{
			if (eventMethodPrefix == "add_")
			{
				return new BinaryExpression(BinaryOperator.AddAssign, target, argument, typeSystem, instructions);
			}
			if (eventMethodPrefix == "remove_")
			{
				return new BinaryExpression(BinaryOperator.SubtractAssign, target, argument, typeSystem, instructions);
			}
			return null;
		}
 public override Expression CloneExpressionOnly()
 {
     Expression targetClone = Target != null ? Target.CloneExpressionOnly() : null;
     EventReferenceExpression result = new EventReferenceExpression(targetClone, Event, null);
     return result;
 }
        public override Expression Clone()
        {
			Expression targetClone = Target != null ? Target.Clone() : null;
			EventReferenceExpression result = new EventReferenceExpression(targetClone, Event, instructions);
			return result;
        }
 public override ICodeNode VisitEventReferenceExpression(EventReferenceExpression node)
 {
     node.Target = (Expression)VisitTargetExpression(node.Target);
     return node;
 }
 public virtual void VisitEventReferenceExpression(EventReferenceExpression node)
 {
     Visit(node.Target);
 }