예제 #1
0
            public static void SerializeDelta(Stream stream, EggHunt.EggHunter instance, EggHunt.EggHunter previous)
            {
                MemoryStream memoryStream = Pool.Get <MemoryStream>();

                if (instance.displayName != null && instance.displayName != previous.displayName)
                {
                    stream.WriteByte(10);
                    ProtocolParser.WriteString(stream, instance.displayName);
                }
                if (instance.numEggs != previous.numEggs)
                {
                    stream.WriteByte(16);
                    ProtocolParser.WriteUInt64(stream, (ulong)instance.numEggs);
                }
                Pool.FreeMemoryStream(ref memoryStream);
            }
예제 #2
0
            public static EggHunt.EggHunter DeserializeLengthDelimited(Stream stream, EggHunt.EggHunter instance, bool isDelta)
            {
                long position = (long)ProtocolParser.ReadUInt32(stream);

                position += stream.Position;
                while (stream.Position < position)
                {
                    int num = stream.ReadByte();
                    if (num == -1)
                    {
                        throw new EndOfStreamException();
                    }
                    if (num == 10)
                    {
                        instance.displayName = ProtocolParser.ReadString(stream);
                    }
                    else if (num == 16)
                    {
                        instance.numEggs = (int)ProtocolParser.ReadUInt64(stream);
                    }
                    else
                    {
                        Key key = ProtocolParser.ReadKey((byte)num, stream);
                        if (key.Field == 0)
                        {
                            throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                        }
                        ProtocolParser.SkipKey(stream, key);
                    }
                }
                if (stream.Position != position)
                {
                    throw new ProtocolBufferException("Read past max limit");
                }
                return(instance);
            }
예제 #3
0
 public static EggHunt.EggHunter DeserializeLengthDelimited(Stream stream)
 {
     EggHunt.EggHunter eggHunter = Pool.Get <EggHunt.EggHunter>();
     EggHunt.EggHunter.DeserializeLengthDelimited(stream, eggHunter, false);
     return(eggHunter);
 }
예제 #4
0
 public static EggHunt.EggHunter DeserializeLength(Stream stream, int length)
 {
     EggHunt.EggHunter eggHunter = Pool.Get <EggHunt.EggHunter>();
     EggHunt.EggHunter.DeserializeLength(stream, length, eggHunter, false);
     return(eggHunter);
 }
예제 #5
0
 public void CopyTo(EggHunt.EggHunter instance)
 {
     instance.displayName = this.displayName;
     instance.numEggs     = this.numEggs;
 }
예제 #6
0
 public EggHunt.EggHunter Copy()
 {
     EggHunt.EggHunter eggHunter = Pool.Get <EggHunt.EggHunter>();
     this.CopyTo(eggHunter);
     return(eggHunter);
 }