protected BattleNetAPI(BattleNetCSharp battlenet, string logSourceName)
 {
     this.m_battleNet    = battlenet;
     this.m_logSource    = new BattleNetLogSource(logSourceName);
     this.m_logDelegates = new BattleNetAPI.LogDelegate[]
     {
         new BattleNetAPI.LogDelegate(this.m_logSource.LogDebug),
         new BattleNetAPI.LogDelegate(this.m_logSource.LogError)
     };
 }
Пример #2
0
 public LogThreadHelper(string name)
 {
     this.m_logSource = new BattleNetLogSource(name);
 }
        private void InitializeInternalState(RPCMeterConfig config, ServiceCollectionHelper serviceHelper)
        {
            string        serviceName;
            string        str;
            List <string> strs        = new List <string>();
            List <string> strs1       = new List <string>();
            int           methodCount = config.MethodCount;

            for (int i = 0; i < methodCount; i++)
            {
                RPCMethodConfig item = config.Method[i];
                RPCConnectionMetering.StaticData staticDatum = new RPCConnectionMetering.StaticData();
                staticDatum.FromProtocol(item);
                if (item.HasServiceName)
                {
                    serviceName = item.ServiceName;
                    ServiceDescriptor importedServiceByName = serviceHelper.GetImportedServiceByName(serviceName);
                    if (importedServiceByName != null)
                    {
                        staticDatum.ServiceId = importedServiceByName.Id;
                        if (!item.HasMethodName)
                        {
                            if (this.m_data.ServiceDefaults.ContainsKey(serviceName))
                            {
                                goto Label1;
                            }
                            this.m_data.ServiceDefaults[serviceName] = staticDatum;
                            this.m_log.LogDebug("Adding Service default {0}", new object[] { staticDatum });
                        }
                        else
                        {
                            string methodName = item.MethodName;
                            str = string.Format("{0}.{1}", serviceName, methodName);
                            MethodDescriptor methodDescriptorByName = importedServiceByName.GetMethodDescriptorByName(str);
                            if (methodDescriptorByName != null)
                            {
                                if (this.m_data.MethodDefaults.ContainsKey(str))
                                {
                                    goto Label2;
                                }
                                staticDatum.MethodId            = methodDescriptorByName.Id;
                                this.m_data.MethodDefaults[str] = staticDatum;
                                this.m_log.LogDebug("Adding Method default {0}", new object[] { staticDatum });
                            }
                            else
                            {
                                this.m_log.LogDebug("Configuration specifies an unused method {0}, ignoring.", new object[] { methodName });
                                goto Label0;
                            }
                        }
                        strs.Add(serviceName);
                    }
                    else if (!strs1.Contains(serviceName))
                    {
                        this.m_log.LogDebug("Ignoring not imported service {0}", new object[] { serviceName });
                        strs1.Add(serviceName);
                    }
                }
                else if (this.m_data.GlobalDefault != null)
                {
                    this.m_log.LogWarning("Static data has two defaults, ignoring additional ones.");
                }
                else
                {
                    this.m_data.GlobalDefault = staticDatum;
                    this.m_log.LogDebug("Adding global default {0}", new object[] { staticDatum });
                }
Label0:
            }
            foreach (KeyValuePair <uint, ServiceDescriptor> importedService in serviceHelper.ImportedServices)
            {
                if (strs.Contains(importedService.Value.Name) || this.m_data.GlobalDefault != null)
                {
                    continue;
                }
                this.m_log.LogDebug("Configuration for service {0} was not found and will not be metered.", new object[] { importedService.Value.Name });
            }
            return;

Label1:
            BattleNetLogSource mLog = this.m_log;

            mLog.LogWarning("Default for service {0} already exists, ignoring extras.", new object[] { serviceName });
            goto Label0;
Label2:
            BattleNetLogSource battleNetLogSource = this.m_log;

            battleNetLogSource.LogWarning("Default for method {0} already exists, ignoring extras.", new object[] { str });
            goto Label0;
        }