Esempio n. 1
0
        public static void Serialize(Stream stream, RPCMeterConfig instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.Method.Count > 0)
            {
                foreach (RPCMethodConfig rpcmethodConfig in instance.Method)
                {
                    stream.WriteByte(10);
                    ProtocolParser.WriteUInt32(stream, rpcmethodConfig.GetSerializedSize());
                    RPCMethodConfig.Serialize(stream, rpcmethodConfig);
                }
            }
            if (instance.HasIncomePerSecond)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt32(stream, instance.IncomePerSecond);
            }
            if (instance.HasInitialBalance)
            {
                stream.WriteByte(24);
                ProtocolParser.WriteUInt32(stream, instance.InitialBalance);
            }
            if (instance.HasCapBalance)
            {
                stream.WriteByte(32);
                ProtocolParser.WriteUInt32(stream, instance.CapBalance);
            }
            if (instance.HasStartupPeriod)
            {
                stream.WriteByte(45);
                binaryWriter.Write(instance.StartupPeriod);
            }
        }
Esempio n. 2
0
        public static RPCMeterConfig DeserializeLengthDelimited(Stream stream, RPCMeterConfig instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.Position;
            return(RPCMeterConfig.Deserialize(stream, instance, num));
        }
Esempio n. 3
0
        public static RPCMeterConfig DeserializeLengthDelimited(Stream stream)
        {
            RPCMeterConfig rpcmeterConfig = new RPCMeterConfig();

            RPCMeterConfig.DeserializeLengthDelimited(stream, rpcmeterConfig);
            return(rpcmeterConfig);
        }
Esempio n. 4
0
        public override bool Equals(object obj)
        {
            RPCMeterConfig rpcmeterConfig = obj as RPCMeterConfig;

            if (rpcmeterConfig == null)
            {
                return(false);
            }
            if (this.Method.Count != rpcmeterConfig.Method.Count)
            {
                return(false);
            }
            for (int i = 0; i < this.Method.Count; i++)
            {
                if (!this.Method[i].Equals(rpcmeterConfig.Method[i]))
                {
                    return(false);
                }
            }
            return(this.HasIncomePerSecond == rpcmeterConfig.HasIncomePerSecond && (!this.HasIncomePerSecond || this.IncomePerSecond.Equals(rpcmeterConfig.IncomePerSecond)) && this.HasInitialBalance == rpcmeterConfig.HasInitialBalance && (!this.HasInitialBalance || this.InitialBalance.Equals(rpcmeterConfig.InitialBalance)) && this.HasCapBalance == rpcmeterConfig.HasCapBalance && (!this.HasCapBalance || this.CapBalance.Equals(rpcmeterConfig.CapBalance)) && this.HasStartupPeriod == rpcmeterConfig.HasStartupPeriod && (!this.HasStartupPeriod || this.StartupPeriod.Equals(rpcmeterConfig.StartupPeriod)));
        }
Esempio n. 5
0
        public static void Serialize(Stream stream, RPCMeterConfig instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.Method.get_Count() > 0)
            {
                using (List <RPCMethodConfig> .Enumerator enumerator = instance.Method.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        RPCMethodConfig current = enumerator.get_Current();
                        stream.WriteByte(10);
                        ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                        RPCMethodConfig.Serialize(stream, current);
                    }
                }
            }
            if (instance.HasIncomePerSecond)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt32(stream, instance.IncomePerSecond);
            }
            if (instance.HasInitialBalance)
            {
                stream.WriteByte(24);
                ProtocolParser.WriteUInt32(stream, instance.InitialBalance);
            }
            if (instance.HasCapBalance)
            {
                stream.WriteByte(32);
                ProtocolParser.WriteUInt32(stream, instance.CapBalance);
            }
            if (instance.HasStartupPeriod)
            {
                stream.WriteByte(45);
                binaryWriter.Write(instance.StartupPeriod);
            }
        }
Esempio n. 6
0
 public void Serialize(Stream stream)
 {
     RPCMeterConfig.Serialize(stream, this);
 }
Esempio n. 7
0
        public static RPCMeterConfig Deserialize(Stream stream, RPCMeterConfig instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            if (instance.Method == null)
            {
                instance.Method = new List <RPCMethodConfig>();
            }
            instance.IncomePerSecond = 1u;
            instance.StartupPeriod   = 0f;
            while (limit < 0L || stream.Position < limit)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    if (limit >= 0L)
                    {
                        throw new EndOfStreamException();
                    }
                    return(instance);
                }
                else if (num != 10)
                {
                    if (num != 16)
                    {
                        if (num != 24)
                        {
                            if (num != 32)
                            {
                                if (num != 45)
                                {
                                    Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                                    uint field = key.Field;
                                    if (field == 0u)
                                    {
                                        throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                                    }
                                    ProtocolParser.SkipKey(stream, key);
                                }
                                else
                                {
                                    instance.StartupPeriod = binaryReader.ReadSingle();
                                }
                            }
                            else
                            {
                                instance.CapBalance = ProtocolParser.ReadUInt32(stream);
                            }
                        }
                        else
                        {
                            instance.InitialBalance = ProtocolParser.ReadUInt32(stream);
                        }
                    }
                    else
                    {
                        instance.IncomePerSecond = ProtocolParser.ReadUInt32(stream);
                    }
                }
                else
                {
                    instance.Method.Add(RPCMethodConfig.DeserializeLengthDelimited(stream));
                }
            }
            if (stream.Position == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
Esempio n. 8
0
 public static RPCMeterConfig Deserialize(Stream stream, RPCMeterConfig instance)
 {
     return(RPCMeterConfig.Deserialize(stream, instance, -1L));
 }