Example #1
0
        public static void Serialize(Stream stream, RPCMethodConfig instance)
        {
            BinaryWriter binaryWriter = new BinaryWriter(stream);

            if (instance.HasServiceName)
            {
                stream.WriteByte(10);
                ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.ServiceName));
            }
            if (instance.HasMethodName)
            {
                stream.WriteByte(18);
                ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.MethodName));
            }
            if (instance.HasFixedCallCost)
            {
                stream.WriteByte(24);
                ProtocolParser.WriteUInt32(stream, instance.FixedCallCost);
            }
            if (instance.HasFixedPacketSize)
            {
                stream.WriteByte(32);
                ProtocolParser.WriteUInt32(stream, instance.FixedPacketSize);
            }
            if (instance.HasVariableMultiplier)
            {
                stream.WriteByte(45);
                binaryWriter.Write(instance.VariableMultiplier);
            }
            if (instance.HasMultiplier)
            {
                stream.WriteByte(53);
                binaryWriter.Write(instance.Multiplier);
            }
            if (instance.HasRateLimitCount)
            {
                stream.WriteByte(56);
                ProtocolParser.WriteUInt32(stream, instance.RateLimitCount);
            }
            if (instance.HasRateLimitSeconds)
            {
                stream.WriteByte(64);
                ProtocolParser.WriteUInt32(stream, instance.RateLimitSeconds);
            }
            if (instance.HasMaxPacketSize)
            {
                stream.WriteByte(72);
                ProtocolParser.WriteUInt32(stream, instance.MaxPacketSize);
            }
            if (instance.HasMaxEncodedSize)
            {
                stream.WriteByte(80);
                ProtocolParser.WriteUInt32(stream, instance.MaxEncodedSize);
            }
            if (instance.HasTimeout)
            {
                stream.WriteByte(93);
                binaryWriter.Write(instance.Timeout);
            }
        }
Example #2
0
        public static RPCMethodConfig DeserializeLengthDelimited(Stream stream)
        {
            RPCMethodConfig rpcmethodConfig = new RPCMethodConfig();

            RPCMethodConfig.DeserializeLengthDelimited(stream, rpcmethodConfig);
            return(rpcmethodConfig);
        }
Example #3
0
        public static RPCMethodConfig DeserializeLengthDelimited(Stream stream, RPCMethodConfig instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.Position;
            return(RPCMethodConfig.Deserialize(stream, instance, num));
        }
Example #4
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);
            }
        }
Example #5
0
        public override int GetHashCode()
        {
            int num = base.GetType().GetHashCode();

            using (List <RPCMethodConfig> .Enumerator enumerator = this.Method.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    RPCMethodConfig current = enumerator.get_Current();
                    num ^= current.GetHashCode();
                }
            }
            if (this.HasIncomePerSecond)
            {
                num ^= this.IncomePerSecond.GetHashCode();
            }
            if (this.HasInitialBalance)
            {
                num ^= this.InitialBalance.GetHashCode();
            }
            if (this.HasCapBalance)
            {
                num ^= this.CapBalance.GetHashCode();
            }
            if (this.HasStartupPeriod)
            {
                num ^= this.StartupPeriod.GetHashCode();
            }
            return(num);
        }
Example #6
0
        public override bool Equals(object obj)
        {
            RPCMethodConfig rPCMethodConfig = obj as RPCMethodConfig;

            if (rPCMethodConfig == null)
            {
                return(false);
            }
            if (this.HasServiceName != rPCMethodConfig.HasServiceName || this.HasServiceName && !this.ServiceName.Equals(rPCMethodConfig.ServiceName))
            {
                return(false);
            }
            if (this.HasMethodName != rPCMethodConfig.HasMethodName || this.HasMethodName && !this.MethodName.Equals(rPCMethodConfig.MethodName))
            {
                return(false);
            }
            if (this.HasFixedCallCost != rPCMethodConfig.HasFixedCallCost || this.HasFixedCallCost && !this.FixedCallCost.Equals(rPCMethodConfig.FixedCallCost))
            {
                return(false);
            }
            if (this.HasFixedPacketSize != rPCMethodConfig.HasFixedPacketSize || this.HasFixedPacketSize && !this.FixedPacketSize.Equals(rPCMethodConfig.FixedPacketSize))
            {
                return(false);
            }
            if (this.HasVariableMultiplier != rPCMethodConfig.HasVariableMultiplier || this.HasVariableMultiplier && !this.VariableMultiplier.Equals(rPCMethodConfig.VariableMultiplier))
            {
                return(false);
            }
            if (this.HasMultiplier != rPCMethodConfig.HasMultiplier || this.HasMultiplier && !this.Multiplier.Equals(rPCMethodConfig.Multiplier))
            {
                return(false);
            }
            if (this.HasRateLimitCount != rPCMethodConfig.HasRateLimitCount || this.HasRateLimitCount && !this.RateLimitCount.Equals(rPCMethodConfig.RateLimitCount))
            {
                return(false);
            }
            if (this.HasRateLimitSeconds != rPCMethodConfig.HasRateLimitSeconds || this.HasRateLimitSeconds && !this.RateLimitSeconds.Equals(rPCMethodConfig.RateLimitSeconds))
            {
                return(false);
            }
            if (this.HasMaxPacketSize != rPCMethodConfig.HasMaxPacketSize || this.HasMaxPacketSize && !this.MaxPacketSize.Equals(rPCMethodConfig.MaxPacketSize))
            {
                return(false);
            }
            if (this.HasMaxEncodedSize != rPCMethodConfig.HasMaxEncodedSize || this.HasMaxEncodedSize && !this.MaxEncodedSize.Equals(rPCMethodConfig.MaxEncodedSize))
            {
                return(false);
            }
            if (this.HasTimeout == rPCMethodConfig.HasTimeout && (!this.HasTimeout || this.Timeout.Equals(rPCMethodConfig.Timeout)))
            {
                return(true);
            }
            return(false);
        }
Example #7
0
        public uint GetSerializedSize()
        {
            uint num = 0u;

            if (this.Method.get_Count() > 0)
            {
                using (List <RPCMethodConfig> .Enumerator enumerator = this.Method.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        RPCMethodConfig current = enumerator.get_Current();
                        num += 1u;
                        uint serializedSize = current.GetSerializedSize();
                        num += serializedSize + ProtocolParser.SizeOfUInt32(serializedSize);
                    }
                }
            }
            if (this.HasIncomePerSecond)
            {
                num += 1u;
                num += ProtocolParser.SizeOfUInt32(this.IncomePerSecond);
            }
            if (this.HasInitialBalance)
            {
                num += 1u;
                num += ProtocolParser.SizeOfUInt32(this.InitialBalance);
            }
            if (this.HasCapBalance)
            {
                num += 1u;
                num += ProtocolParser.SizeOfUInt32(this.CapBalance);
            }
            if (this.HasStartupPeriod)
            {
                num += 1u;
                num += 4u;
            }
            return(num);
        }
Example #8
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);
            }
        }
Example #9
0
 public void Serialize(Stream stream)
 {
     RPCMethodConfig.Serialize(stream, this);
 }
Example #10
0
        public static RPCMethodConfig Deserialize(Stream stream, RPCMethodConfig instance, long limit)
        {
            BinaryReader binaryReader = new BinaryReader(stream);

            instance.FixedCallCost      = 1u;
            instance.FixedPacketSize    = 0u;
            instance.VariableMultiplier = 0f;
            instance.Multiplier         = 1f;
            while (limit < 0L || stream.Position < limit)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    if (limit >= 0L)
                    {
                        throw new EndOfStreamException();
                    }
                    return(instance);
                }
                else
                {
                    switch (num)
                    {
                    case 53:
                        instance.Multiplier = binaryReader.ReadSingle();
                        break;

                    default:
                        if (num != 10)
                        {
                            if (num != 18)
                            {
                                if (num != 24)
                                {
                                    if (num != 32)
                                    {
                                        if (num != 45)
                                        {
                                            if (num != 64)
                                            {
                                                if (num != 72)
                                                {
                                                    if (num != 80)
                                                    {
                                                        if (num != 93)
                                                        {
                                                            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.Timeout = binaryReader.ReadSingle();
                                                        }
                                                    }
                                                    else
                                                    {
                                                        instance.MaxEncodedSize = ProtocolParser.ReadUInt32(stream);
                                                    }
                                                }
                                                else
                                                {
                                                    instance.MaxPacketSize = ProtocolParser.ReadUInt32(stream);
                                                }
                                            }
                                            else
                                            {
                                                instance.RateLimitSeconds = ProtocolParser.ReadUInt32(stream);
                                            }
                                        }
                                        else
                                        {
                                            instance.VariableMultiplier = binaryReader.ReadSingle();
                                        }
                                    }
                                    else
                                    {
                                        instance.FixedPacketSize = ProtocolParser.ReadUInt32(stream);
                                    }
                                }
                                else
                                {
                                    instance.FixedCallCost = ProtocolParser.ReadUInt32(stream);
                                }
                            }
                            else
                            {
                                instance.MethodName = ProtocolParser.ReadString(stream);
                            }
                        }
                        else
                        {
                            instance.ServiceName = ProtocolParser.ReadString(stream);
                        }
                        break;

                    case 56:
                        instance.RateLimitCount = ProtocolParser.ReadUInt32(stream);
                        break;
                    }
                }
            }
            if (stream.Position == limit)
            {
                return(instance);
            }
            throw new ProtocolBufferException("Read past max limit");
        }
Example #11
0
 public static RPCMethodConfig Deserialize(Stream stream, RPCMethodConfig instance)
 {
     return(RPCMethodConfig.Deserialize(stream, instance, -1L));
 }
Example #12
0
        public override bool Equals(object obj)
        {
            RPCMethodConfig rpcmethodConfig = obj as RPCMethodConfig;

            return(rpcmethodConfig != null && this.HasServiceName == rpcmethodConfig.HasServiceName && (!this.HasServiceName || this.ServiceName.Equals(rpcmethodConfig.ServiceName)) && this.HasMethodName == rpcmethodConfig.HasMethodName && (!this.HasMethodName || this.MethodName.Equals(rpcmethodConfig.MethodName)) && this.HasFixedCallCost == rpcmethodConfig.HasFixedCallCost && (!this.HasFixedCallCost || this.FixedCallCost.Equals(rpcmethodConfig.FixedCallCost)) && this.HasFixedPacketSize == rpcmethodConfig.HasFixedPacketSize && (!this.HasFixedPacketSize || this.FixedPacketSize.Equals(rpcmethodConfig.FixedPacketSize)) && this.HasVariableMultiplier == rpcmethodConfig.HasVariableMultiplier && (!this.HasVariableMultiplier || this.VariableMultiplier.Equals(rpcmethodConfig.VariableMultiplier)) && this.HasMultiplier == rpcmethodConfig.HasMultiplier && (!this.HasMultiplier || this.Multiplier.Equals(rpcmethodConfig.Multiplier)) && this.HasRateLimitCount == rpcmethodConfig.HasRateLimitCount && (!this.HasRateLimitCount || this.RateLimitCount.Equals(rpcmethodConfig.RateLimitCount)) && this.HasRateLimitSeconds == rpcmethodConfig.HasRateLimitSeconds && (!this.HasRateLimitSeconds || this.RateLimitSeconds.Equals(rpcmethodConfig.RateLimitSeconds)) && this.HasMaxPacketSize == rpcmethodConfig.HasMaxPacketSize && (!this.HasMaxPacketSize || this.MaxPacketSize.Equals(rpcmethodConfig.MaxPacketSize)) && this.HasMaxEncodedSize == rpcmethodConfig.HasMaxEncodedSize && (!this.HasMaxEncodedSize || this.MaxEncodedSize.Equals(rpcmethodConfig.MaxEncodedSize)) && this.HasTimeout == rpcmethodConfig.HasTimeout && (!this.HasTimeout || this.Timeout.Equals(rpcmethodConfig.Timeout)));
        }
Example #13
0
 public void AddMethod(RPCMethodConfig val)
 {
     this._Method.Add(val);
 }
Example #14
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");
        }