Esempio n. 1
0
        internal static SerializableMemberInfo FromStream(ZetboxStreamReader binReader)
        {
            var type = binReader.ReadByte();

            switch (type)
            {
            case 0:
                return(new SerializableMemberInfo()
                {
                    Name = binReader.ReadString(),
                    Type = binReader.ReadSerializableType(),
                });

            case 1:
                return(new SerializableConstructorInfo()
                {
                    Name = binReader.ReadString(),
                    Type = binReader.ReadSerializableType(),
                    ParameterTypes = SerializableExpression.ReadTypeArray(binReader)
                });

            default:
                throw new NotImplementedException(String.Format("unrecognized SerializableMemberInfoType [{0}]", type));
            }
        }
Esempio n. 2
0
        internal static SerializableExpression FromStream(ZetboxStreamReader binStream, StreamSerializationContext ctx, InterfaceType.Factory iftFactory)
        {
            var type = (SerializableExpressionType)binStream.ReadByte();

            switch (type)
            {
            case SerializableExpressionType.Binary:
                return(new SerializableBinaryExpression(binStream, ctx, iftFactory));

            case SerializableExpressionType.Unary:
                return(new SerializableUnaryExpression(binStream, ctx, iftFactory));

            case SerializableExpressionType.Constant:
                return(new SerializableConstantExpression(binStream, ctx, iftFactory));

            case SerializableExpressionType.Member:
                return(new SerializableMemberExpression(binStream, ctx, iftFactory));

            case SerializableExpressionType.MethodCall:
                return(new SerializableMethodCallExpression(binStream, ctx, iftFactory));

            case SerializableExpressionType.Lambda:
                return(new SerializableLambdaExpression(binStream, ctx, iftFactory));

            case SerializableExpressionType.Parameter:
                var parameterGuid = new Guid(binStream.ReadString());
                if (ctx.Parameter.ContainsKey(parameterGuid))
                {
                    return(ctx.Parameter[parameterGuid]);
                }
                else
                {
                    return(ctx.Parameter[parameterGuid] = new SerializableParameterExpression(binStream, ctx, iftFactory, parameterGuid));
                }

            case SerializableExpressionType.New:
                return(new SerializableNewExpression(binStream, ctx, iftFactory));

            case SerializableExpressionType.Conditional:
                return(new SerializableConditionalExpression(binStream, ctx, iftFactory));

            default:
                throw new NotImplementedException(string.Format("Unknown SerializableExpressionType encountered: [{0}]", type));
            }
        }