protected internal override void VisitListInit(SerializableListInitExpression node)
 {
     Visit(node.NewExpression);
     Out(" {");
     for (int i = 0, n = node.Initializers.Count; i < n; i++)
     {
         if (i > 0)
         {
             Out(", ");
         }
         Out(node.Initializers[i].ToString());
     }
     Out("}");
 }
Exemplo n.º 2
0
 protected internal abstract void VisitListInit(SerializableListInitExpression node);
 public SerializableExpression TryConvert(Expression expression)
 {
     if (expression == null)
     {
         return(null);
     }
     else if (serialized.ContainsKey(expression))
     {
         /* Caching is required to maintain object references during serialization.
          * See the comments on SerializableExpression.ConvertWithCache for more info.
          */
         return(serialized[expression]);
     }
     else if ((methodCall = expression as MethodCallExpression) != null)
     {
         return(serialized[expression] = new SerializableMethodCallExpression(methodCall, this));
     }
     else if ((lambda = expression as LambdaExpression) != null)
     {
         return(serialized[expression] = new SerializableLambdaExpression(lambda, this));
     }
     else if ((constant = expression as ConstantExpression) != null)
     {
         return(serialized[expression] = new SerializableConstantExpression(constant));
     }
     else if ((member = expression as MemberExpression) != null)
     {
         return(serialized[expression] = new SerializableMemberExpression(member, this));
     }
     else if ((binary = expression as BinaryExpression) != null)
     {
         return(serialized[expression] = new SerializableBinaryExpression(binary, this));
     }
     else if ((block = expression as BlockExpression) != null)
     {
         return(serialized[expression] = new SerializableBlockExpression(block, this));
     }
     else if ((conditional = expression as ConditionalExpression) != null)
     {
         return(serialized[expression] = new SerializableConditionalExpression(conditional, this));
     }
     else if ((@default = expression as DefaultExpression) != null)
     {
         return(serialized[expression] = new SerializableDefaultExpression(@default));
     }
     else if ((@goto = expression as GotoExpression) != null)
     {
         return(serialized[expression] = new SerializableGotoExpression(@goto, this));
     }
     else if ((index = expression as IndexExpression) != null)
     {
         return(serialized[expression] = new SerializableIndexExpression(index, this));
     }
     else if ((invocation = expression as InvocationExpression) != null)
     {
         return(serialized[expression] = new SerializableInvocationExpression(invocation, this));
     }
     else if ((label = expression as LabelExpression) != null)
     {
         return(serialized[expression] = new SerializableLabelExpression(label, this));
     }
     else if ((listInit = expression as ListInitExpression) != null)
     {
         return(serialized[expression] = new SerializableListInitExpression(listInit, this));
     }
     else if ((loop = expression as LoopExpression) != null)
     {
         return(serialized[expression] = new SerializableLoopExpression(loop, this));
     }
     else if ((memberInit = expression as MemberInitExpression) != null)
     {
         return(serialized[expression] = new SerializableMemberInitExpression(memberInit, this));
     }
     else if ((newArray = expression as NewArrayExpression) != null)
     {
         return(serialized[expression] = new SerializableNewArrayExpression(newArray, this));
     }
     else if ((@new = expression as NewExpression) != null)
     {
         return(serialized[expression] = new SerializableNewExpression(@new, this));
     }
     else if ((parameter = expression as ParameterExpression) != null)
     {
         return(serialized[expression] = new SerializableParameterExpression(parameter));
     }
     else if ((runtimeVariables = expression as RuntimeVariablesExpression) != null)
     {
         return(serialized[expression] = new SerializableRuntimeVariablesExpression(runtimeVariables, this));
     }
     else if ((@switch = expression as SwitchExpression) != null)
     {
         return(serialized[expression] = new SerializableSwitchExpression(@switch, this));
     }
     else if ((@try = expression as TryExpression) != null)
     {
         return(serialized[expression] = new SerializableTryExpression(@try, this));
     }
     else if ((typeBinary = expression as TypeBinaryExpression) != null)
     {
         return(serialized[expression] = new SerializableTypeBinaryExpression(typeBinary, this));
     }
     else if ((unary = expression as UnaryExpression) != null)
     {
         return(serialized[expression] = new SerializableUnaryExpression(unary, this));
     }
     else
     {
         throw new ArgumentOutOfRangeException("expression");
     }
 }