예제 #1
0
        public static RPCMeterConfig ParseConfig(string str)
        {
            RPCMeterConfig rpcmeterConfig = new RPCMeterConfig();
            Tokenizer      tokenizer      = new Tokenizer(str);

            for (;;)
            {
                string text = tokenizer.NextString();
                if (text == null)
                {
                    break;
                }
                if (text == null)
                {
                    goto IL_CF;
                }
                if (!(text == "method"))
                {
                    if (!(text == "income_per_second:"))
                    {
                        if (!(text == "initial_balance:"))
                        {
                            if (!(text == "cap_balance:"))
                            {
                                if (!(text == "startup_period:"))
                                {
                                    goto IL_CF;
                                }
                                rpcmeterConfig.StartupPeriod = tokenizer.NextFloat();
                            }
                            else
                            {
                                rpcmeterConfig.CapBalance = tokenizer.NextUInt32();
                            }
                        }
                        else
                        {
                            rpcmeterConfig.InitialBalance = tokenizer.NextUInt32();
                        }
                    }
                    else
                    {
                        rpcmeterConfig.IncomePerSecond = tokenizer.NextUInt32();
                    }
                }
                else
                {
                    rpcmeterConfig.AddMethod(RPCMeterConfigParser.ParseMethod(tokenizer));
                }
                continue;
IL_CF:
                tokenizer.SkipUnknownToken();
            }
            return(rpcmeterConfig);
        }
예제 #2
0
        public static RPCMeterConfig ParseConfig(string str)
        {
            RPCMeterConfig rPCMeterConfig = new RPCMeterConfig();
            Tokenizer      tokenizer      = new Tokenizer(str);

            while (true)
            {
Label2:
                string str1 = tokenizer.NextString();
                if (str1 == null)
                {
                    break;
                }
                if (str1 == null)
                {
                    goto Label0;
                }
                else if (str1 == "method")
                {
                    rPCMeterConfig.AddMethod(RPCMeterConfigParser.ParseMethod(tokenizer));
                }
                else if (str1 == "income_per_second:")
                {
                    rPCMeterConfig.IncomePerSecond = tokenizer.NextUInt32();
                }
                else if (str1 == "initial_balance:")
                {
                    rPCMeterConfig.InitialBalance = tokenizer.NextUInt32();
                }
                else if (str1 == "cap_balance:")
                {
                    rPCMeterConfig.CapBalance = tokenizer.NextUInt32();
                }
                else
                {
                    if (str1 != "startup_period:")
                    {
                        goto Label0;
                    }
                    rPCMeterConfig.StartupPeriod = tokenizer.NextFloat();
                }
            }
            return(rPCMeterConfig);

Label0:
            tokenizer.SkipUnknownToken();
            goto Label2;
        }
 public void SetConnectionMeteringData(byte[] data, ServiceCollectionHelper serviceHelper)
 {
     this.m_data = new RPCConnectionMetering.MeteringData();
     if (data == null || data.Length == 0 || serviceHelper == null)
     {
         this.m_log.LogError("Unable to retrieve Connection Metering data");
         return;
     }
     try
     {
         RPCMeterConfig rpcmeterConfig = RPCMeterConfigParser.ParseConfig(Encoding.ASCII.GetString(data));
         if (rpcmeterConfig == null || !rpcmeterConfig.IsInitialized)
         {
             this.m_data = null;
             throw new Exception("Unable to parse metering config protocol buffer.");
         }
         this.UpdateConfigStats(rpcmeterConfig);
         if (rpcmeterConfig.HasStartupPeriod)
         {
             this.m_data.StartupPeriodDuration = rpcmeterConfig.StartupPeriod;
             this.m_data.StartupPeriodEnd      = (float)BattleNet.GetRealTimeSinceStartup() + rpcmeterConfig.StartupPeriod;
             this.m_log.LogDebug("StartupPeriod={0}", new object[]
             {
                 rpcmeterConfig.StartupPeriod
             });
             this.m_log.LogDebug("StartupPeriodEnd={0}", new object[]
             {
                 this.m_data.StartupPeriodEnd
             });
         }
         this.InitializeInternalState(rpcmeterConfig, serviceHelper);
     }
     catch (Exception ex)
     {
         this.m_data = null;
         this.m_log.LogError("EXCEPTION = {0} {1}", new object[]
         {
             ex.Message,
             ex.StackTrace
         });
     }
     if (this.m_data == null)
     {
         this.m_log.LogError("Unable to parse Connection Metering data");
     }
 }
예제 #4
0
        public static RPCMeterConfig ParseConfig(string str)
        {
            RPCMeterConfig rPCMeterConfig = new RPCMeterConfig();
            Tokenizer      tokenizer      = new Tokenizer(str);

            while (true)
            {
                string text = tokenizer.NextString();
                if (text == null)
                {
                    break;
                }
                string text2 = text;
                if (text2 == null)
                {
                    goto IL_108;
                }
                if (RPCMeterConfigParser.< > f__switch$mapD == null)
                {
                    Dictionary <string, int> dictionary = new Dictionary <string, int>(5);
                    dictionary.Add("method", 0);
                    dictionary.Add("income_per_second:", 1);
                    dictionary.Add("initial_balance:", 2);
                    dictionary.Add("cap_balance:", 3);
                    dictionary.Add("startup_period:", 4);
                    RPCMeterConfigParser.< > f__switch$mapD = dictionary;
                }
                int num;
                if (!RPCMeterConfigParser.< > f__switch$mapD.TryGetValue(text2, ref num))
                {
                    goto IL_108;
                }
                switch (num)
                {
                case 0:
                    rPCMeterConfig.AddMethod(RPCMeterConfigParser.ParseMethod(tokenizer));
                    break;

                case 1:
                    rPCMeterConfig.IncomePerSecond = tokenizer.NextUInt32();
                    break;

                case 2:
                    rPCMeterConfig.InitialBalance = tokenizer.NextUInt32();
                    break;

                case 3:
                    rPCMeterConfig.CapBalance = tokenizer.NextUInt32();
                    break;

                case 4:
                    rPCMeterConfig.StartupPeriod = tokenizer.NextFloat();
                    break;

                default:
                    goto IL_108;
                }
                continue;
IL_108:
                tokenizer.SkipUnknownToken();
            }
            return(rPCMeterConfig);
        }