internal SerializableConditionalExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) : base(binReader, ctx, iftFactory) { Test = SerializableExpression.FromStream(binReader, ctx, iftFactory); IfTrue = SerializableExpression.FromStream(binReader, ctx, iftFactory); IfFalse = SerializableExpression.FromStream(binReader, ctx, iftFactory); }
internal override void ToStream(ZetboxStreamWriter binStream, StreamSerializationContext ctx) { binStream.Write((byte)SerializableExpressionType.Constant); base.ToStream(binStream, ctx); binStream.Write(Value); }
internal SerializableConstantExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) : base(binReader, ctx, iftFactory) { object val; binReader.Read(out val, Type); Value = val; }
internal override void ToStream(ZetboxStreamWriter binStream, StreamSerializationContext ctx) { binStream.Write((byte)SerializableExpressionType.Conditional); base.ToStream(binStream, ctx); Test.ToStream(binStream, ctx); IfTrue.ToStream(binStream, ctx); IfFalse.ToStream(binStream, ctx); }
/// <summary> /// Writes this SerializableExpression to the specified stream. /// </summary> /// <param name="binStream"></param> public void ToStream(ZetboxStreamWriter binStream) { if (binStream == null) { throw new ArgumentNullException("binStream"); } var ctx = new StreamSerializationContext(); ToStream(binStream, ctx); }
internal override void ToStream(ZetboxStreamWriter binStream, StreamSerializationContext ctx) { // do net render SerializableExpressionType for abstract, intermediate class base.ToStream(binStream, ctx); for (int i = 0; i < Children.Length; i++) { binStream.Write(true); Children[i].ToStream(binStream, ctx); } binStream.Write(false); }
internal SerializableCompoundExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) : base(binReader, ctx, iftFactory) { var children = new List <SerializableExpression>(); while (binReader.ReadBoolean()) { children.Add(SerializableExpression.FromStream(binReader, ctx, iftFactory)); } this.Children = children.ToArray(); }
internal override void ToStream(ZetboxStreamWriter binStream, StreamSerializationContext ctx) { binStream.Write((byte)SerializableExpressionType.New); base.ToStream(binStream, ctx); Constructor.ToStream(binStream); for (int i = 0; i < Members.Length; i++) { binStream.Write(true); Members[i].ToStream(binStream); } binStream.Write(false); }
internal SerializableNewExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) : base(binReader, ctx, iftFactory) { Constructor = (SerializableConstructorInfo)SerializableMemberInfo.FromStream(binReader); var members = new List <SerializableMemberInfo>(); while (binReader.ReadBoolean()) { members.Add(SerializableMemberInfo.FromStream(binReader)); } this.Members = members.ToArray(); }
internal SerializableExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) { this.iftFactory = iftFactory; SerializableType t; binReader.Read(out t); this.SerializableType = t; int nt; binReader.Read(out nt); NodeType = nt; }
internal SerializableMethodCallExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) : base(binReader, ctx, iftFactory) { var hasObject = binReader.ReadBoolean(); if (hasObject) { ObjectExpression = SerializableExpression.FromStream(binReader, ctx, iftFactory); } MethodName = binReader.ReadString(); SerializableMethodType = binReader.ReadSerializableType(); ParameterTypes = ReadTypeArray(binReader); GenericArguments = ReadTypeArray(binReader); }
internal override void ToStream(ZetboxStreamWriter binStream, StreamSerializationContext ctx) { binStream.Write((byte)SerializableExpressionType.Parameter); binStream.Write(this.Guid.ToString()); // shortcut serialization if we already went into the stream at an earlier position if (ctx.Parameter.ContainsKey(this.Guid)) { return; } else { ctx.Parameter[this.Guid] = this; } base.ToStream(binStream, ctx); binStream.Write(this.Name); }
internal override void ToStream(ZetboxStreamWriter binStream, StreamSerializationContext ctx) { binStream.Write((byte)SerializableExpressionType.MethodCall); base.ToStream(binStream, ctx); if (this.ObjectExpression != null) { binStream.Write(true); this.ObjectExpression.ToStream(binStream, ctx); } else { binStream.Write(false); } binStream.Write(MethodName); binStream.Write(this.SerializableMethodType); WriteTypeArray(binStream, ParameterTypes); WriteTypeArray(binStream, GenericArguments); }
internal SerializableParameterExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory, Guid parameterGuid) : base(binReader, ctx, iftFactory) { this.Name = binReader.ReadString(); this.Guid = parameterGuid; }
internal SerializableLambdaExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) : base(binReader, ctx, iftFactory) { }
/// <remarks> /// Inheriting classes need to first write their SerializableExpressionType as byte to the stream, then call this method to write out basic infromation. Afterwards they are free to implement their own members. /// </remarks> internal virtual void ToStream(ZetboxStreamWriter binStream, StreamSerializationContext ctx) { binStream.Write(this.SerializableType); binStream.Write(this.NodeType); }
internal override void ToStream(ZetboxStreamWriter binStream, StreamSerializationContext ctx) { binStream.Write((byte)SerializableExpressionType.Member); base.ToStream(binStream, ctx); binStream.Write(this.MemberName); }
internal SerializableMemberExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) : base(binReader, ctx, iftFactory) { MemberName = binReader.ReadString(); }
public static SerializableExpression FromStream(ZetboxStreamReader binStream, InterfaceType.Factory iftFactory) { StreamSerializationContext ctx = new StreamSerializationContext(); return(FromStream(binStream, ctx, iftFactory)); }
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)); } }