Esempio n. 1
0
 //
 // Summary:
 //     Visits the children of the System.Linq.Expressions.MemberBinding.
 //
 // Parameters:
 //   node:
 //     The expression to visit.
 //
 // Returns:
 //     The modified expression, if it or any subexpression was modified; otherwise,
 //     returns the original expression.
 protected override MemberBinding VisitMemberBinding(MemberBinding node)
 {
     Console.WriteLine("VisitMemberBinding:");
     Console.WriteLine('\t' + node.GetType().ToString());
     Console.WriteLine('\t' + node.ToString());
     return(base.VisitMemberBinding(node));
 }
Esempio n. 2
0
 public static IMemberBindingMutator GetMutator(MemberBinding memberBinding)
 {
     if (memberBinding is MemberAssignment)
     {
         return(new MemberAssignmentMutator((MemberAssignment)memberBinding));
     }
     if (memberBinding is MemberMemberBinding)
     {
         return(new MemberMemberBindingMutator((MemberMemberBinding)memberBinding));
     }
     if (memberBinding is MemberListBinding)
     {
         return(new MemberListBindingMutator((MemberListBinding)memberBinding));
     }
     throw Error.BadArgument("S0040: Unknown Expression Type '{0}'", memberBinding.GetType());
 }
Esempio n. 3
0
        internal static MemberBindingNode Create(INodeFactory factory, MemberBinding memberBinding)
        {
            MemberBindingNode memberBindingNode = null;

            if (memberBinding is MemberAssignment)
            {
                memberBindingNode = new MemberAssignmentNode(factory, (MemberAssignment)memberBinding);
            }
            else if (memberBinding is MemberListBinding)
            {
                memberBindingNode = new MemberListBindingNode(factory, (MemberListBinding)memberBinding);
            }
            else if (memberBinding is MemberMemberBinding)
            {
                memberBindingNode = new MemberMemberBindingNode(factory, (MemberMemberBinding)memberBinding);
            }
            else if (memberBinding != null)
            {
                throw new ArgumentException("Unknown member binding of type " + memberBinding.GetType(), "memberBinding");
            }

            return(memberBindingNode);
        }
Esempio n. 4
0
 protected override MemberBinding VisitMemberBinding(MemberBinding node)
 {
     throw new NotSupportedException(node.GetType().Name);
 }
Esempio n. 5
0
 protected override MemberBinding VisitMemberBinding(MemberBinding node)
 {
     throw new NotSupportedException($"Node type {node.GetType().Name} is not supported.");
 }
Esempio n. 6
0
        protected virtual MemberBinding VisitMemberBinding(MemberBinding memberBinding)
        {
            ArgumentUtility.CheckNotNull("memberBinding", memberBinding);
            switch (memberBinding.BindingType)
            {
            case MemberBindingType.Assignment:
                return(VisitMemberAssignment((MemberAssignment)memberBinding));

            case MemberBindingType.MemberBinding:
                return(VisitMemberMemberBinding((MemberMemberBinding)memberBinding));

            default:
                Assertion.DebugAssert(
                    memberBinding.BindingType == MemberBindingType.ListBinding, "Invalid member binding type " + memberBinding.GetType().FullName);
                return(VisitMemberListBinding((MemberListBinding)memberBinding));
            }
        }
 /// <param name="node">The expression to visit.</param>
 /// <returns>The modified expression, if it or any subexpression was modified; otherwise, returns the original expression.</returns>
 protected override MemberBinding VisitMemberBinding(MemberBinding node)
 {
     throw new NotSupportedException(string.Format(Resources.EX_PROCESS_NODE_NOT_SUPPORT, node.GetType().Name));
 }
        /// <summary>Converts to serializable.</summary>
        /// <param name="memberBinding">The memberBindings.</param>
        /// <returns>Serializable version.</returns>
        public static MemberBindingRepresentationBase ToRepresentation(
            this MemberBinding memberBinding)
        {
            if (memberBinding == null)
            {
                throw new ArgumentNullException(nameof(memberBinding));
            }

            if (memberBinding is MemberAssignment memberAssignment)
            {
                return(memberAssignment.ToRepresentation());
            }
            else if (memberBinding is MemberListBinding memberListBinding)
            {
                return(memberListBinding.ToRepresentation());
            }
            else if (memberBinding is MemberMemberBinding memberMemberBinding)
            {
                return(memberMemberBinding.ToRepresentation());
            }
            else
            {
                throw new NotSupportedException(Invariant($"Type of {nameof(MemberBinding)} '{memberBinding.GetType()}' is not supported."));
            }
        }
Esempio n. 9
0
 void DispatchMemberBinding(MemberBinding mb)
 {
     Sink(mb.Member.Name + " = ");
     if (mb is MemberMemberBinding)
     {
         var mmb = (MemberMemberBinding)mb;
         Sink("{ ");
         JoinDispatch(mmb.Bindings, ", ", DispatchMemberBinding);
         Sink(" }");
     }
     else if (mb is MemberListBinding)
     {
         var mlb = (MemberListBinding)mb;
         Sink("{ ");
         JoinDispatch(mlb.Initializers, ", ", DispatchElementInit);
         Sink(" }");
     }
     else if (mb is MemberAssignment)
     {
         RawChildDispatch(((MemberAssignment)mb).Expression);
     }
     else
     {
         throw new NotImplementedException("Member binding of unknown type: " + mb.GetType());
     }
 }
Esempio n. 10
0
        private bool Equals(MemberBinding x, Expression y)
        {
            if (x.BindingType == MemberBindingType.MemberBinding && y.NodeType == ExpressionType.MemberInit)
            {
                return(Equals((MemberMemberBinding)x, (MemberInitExpression)y));
            }

            if (x.BindingType == MemberBindingType.ListBinding && y.NodeType == ExpressionType.ListInit)
            {
                return(Equals((MemberListBinding)x, (ListInitExpression)y));
            }

            throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Cannot compare member binding of type '{0}' with expression of type '{1}'", x.GetType().FullName, y.GetType().FullName));
        }