/// <summary> Read an <c>ActivationAddress</c> value from the stream. </summary> /// <returns>Data from current position in stream, converted to the appropriate output type.</returns> internal static ActivationAddress ReadActivationAddress(this IBinaryTokenStreamReader @this) { var silo = @this.ReadSiloAddress(); var grain = @this.ReadGrainId(); var act = @this.ReadActivationId(); if (silo.Equals(SiloAddress.Zero)) { silo = null; } if (act.Equals(ActivationId.Zero)) { act = null; } return(ActivationAddress.GetAddress(silo, grain, act)); }
internal static bool TryReadSimpleType(this IBinaryTokenStreamReader @this, out object result, out SerializationTokenType token) { token = @this.ReadToken(); byte[] bytes; switch (token) { case SerializationTokenType.True: result = true; break; case SerializationTokenType.False: result = false; break; case SerializationTokenType.Null: result = null; break; case SerializationTokenType.Object: result = new object(); break; case SerializationTokenType.Int: result = @this.ReadInt(); break; case SerializationTokenType.Uint: result = @this.ReadUInt(); break; case SerializationTokenType.Short: result = @this.ReadShort(); break; case SerializationTokenType.Ushort: result = @this.ReadUShort(); break; case SerializationTokenType.Long: result = @this.ReadLong(); break; case SerializationTokenType.Ulong: result = @this.ReadULong(); break; case SerializationTokenType.Byte: result = @this.ReadByte(); break; case SerializationTokenType.Sbyte: result = @this.ReadSByte(); break; case SerializationTokenType.Float: result = @this.ReadFloat(); break; case SerializationTokenType.Double: result = @this.ReadDouble(); break; case SerializationTokenType.Decimal: result = @this.ReadDecimal(); break; case SerializationTokenType.String: result = @this.ReadString(); break; case SerializationTokenType.Character: result = @this.ReadChar(); break; case SerializationTokenType.Guid: bytes = @this.ReadBytes(16); result = new Guid(bytes); break; case SerializationTokenType.Date: result = DateTime.FromBinary(@this.ReadLong()); break; case SerializationTokenType.TimeSpan: result = new TimeSpan(@this.ReadLong()); break; case SerializationTokenType.GrainId: result = @this.ReadGrainId(); break; case SerializationTokenType.ActivationId: result = @this.ReadActivationId(); break; case SerializationTokenType.SiloAddress: result = @this.ReadSiloAddress(); break; case SerializationTokenType.ActivationAddress: result = @this.ReadActivationAddress(); break; case SerializationTokenType.IpAddress: result = @this.ReadIPAddress(); break; case SerializationTokenType.IpEndPoint: result = @this.ReadIPEndPoint(); break; case SerializationTokenType.CorrelationId: result = new CorrelationId(@this.ReadBytes(CorrelationId.SIZE_BYTES)); break; default: result = null; return(false); } return(true); }