Ejemplo n.º 1
0
 public static void OnUpdated(Service service, UpdateFeatureMatrix op)
 {
     if (FeatureMatrix.onUpdated != null)
     {
         FeatureMatrix.onUpdated(service, op);
     }
 }
Ejemplo n.º 2
0
 private void WritePreds()
 {
     if (FeatureMatrix.IsEnable("ServiceReporter_ToDB"))
     {
         this.WritePredsToDB();
     }
     if (FeatureMatrix.IsEnable("ServiceReporter_ToCSV"))
     {
         this.WritePredsToCsv();
     }
 }
Ejemplo n.º 3
0
        public static bool IsEnable(string featureName)
        {
            if (featureName == null || featureName.Length == 0)
            {
                return(true);
            }
            if (featureName.IndexOf("||") >= 0)
            {
                string[] separator = new string[]
                {
                    "||"
                };
                string[] array = featureName.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length >= 2)
                {
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (FeatureMatrix.IsEnable(array[i]))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
            }
            if (featureName.IndexOf("&&") >= 0)
            {
                string[] separator2 = new string[]
                {
                    "&&"
                };
                string[] array2 = featureName.Split(separator2, StringSplitOptions.RemoveEmptyEntries);
                if (array2.Length >= 2)
                {
                    for (int j = 0; j < array2.Length; j++)
                    {
                        if (!FeatureMatrix.IsEnable(array2[j]))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            featureName = featureName.Trim();
            if (featureName[0] == '!')
            {
                return(!FeatureMatrix.IsEnable(featureName.Substring(1)));
            }
            string @string = FeatureMatrix.GetString(featureName);

            return(@string != null && @string.Length > 0 && FeatureMatrix.CurrentVer.CompareTo(@string) >= 0);
        }
Ejemplo n.º 4
0
        public static void StartService(string ip, string portstr, Service service, bool bUsePerfLog)
        {
            int       port      = int.Parse(portstr);
            IPAddress ipaddress = null;

            foreach (IPAddress ipaddress2 in Dns.GetHostAddresses(ip))
            {
                if (ipaddress2.AddressFamily == AddressFamily.InterNetwork)
                {
                    ipaddress = ipaddress2;
                    break;
                }
            }
            if (ipaddress == null)
            {
                Log <ServiceInvoker> .Logger.ErrorFormat("cannot resolve IPv4 address for hostname [{0}]", ip);

                return;
            }
            IPEndPoint arg = new IPEndPoint(ipaddress, port);

            if (FeatureMatrix.IsEnable("FeatureMatrixSyncService"))
            {
                FeatureMatrix.OverrideFeature(EventLoader.GetStartEventList());
            }
            Type typeFromHandle = typeof(UpdateFeatureMatrix);
            Func <Operation, OperationProcessor> func = (Operation op) => new UpdateFeatureMatrixProcessor(service, op as UpdateFeatureMatrix);
            MethodInfo method = service.GetType().GetMethod("RegisterProcessor", BindingFlags.Instance | BindingFlags.NonPublic);

            method.Invoke(service, new object[]
            {
                typeFromHandle,
                func
            });
            JobProcessor jobProcessor = new JobProcessor();

            service.Initialize(jobProcessor);
            UnifiedNetwork.LocationService.LookUp @object = new UnifiedNetwork.LocationService.LookUp(service);
            jobProcessor.Start();
            service.AddBootStep();
            jobProcessor.Enqueue(Job.Create <IPEndPoint>(new Action <IPEndPoint>(@object.StartService), arg));
            if (bUsePerfLog)
            {
                PerformanceLogger performanceLogger = new PerformanceLogger(service, 300000);
                performanceLogger.Start();
            }
        }
Ejemplo n.º 5
0
        public static float GetFloat(string featureName)
        {
            string @string = FeatureMatrix.GetString(featureName);
            float  result;

            try
            {
                result = float.Parse(@string);
            }
            catch (FormatException)
            {
                Log <FeatureMatrix> .Logger.ErrorFormat("Not a Float value - Feature {0}='{1}'", featureName, @string);

                result = 0f;
            }
            return(result);
        }
Ejemplo n.º 6
0
        public static int GetInteger(string featureName)
        {
            string @string = FeatureMatrix.GetString(featureName);
            int    result;

            try
            {
                result = int.Parse(@string);
            }
            catch (FormatException)
            {
                Log <FeatureMatrix> .Logger.ErrorFormat("Not an Integer value - Feature {0}='{1}'", featureName, @string);

                result = 0;
            }
            return(result);
        }
Ejemplo n.º 7
0
        public static bool IsMatchServerCode(string stringCode)
        {
            if (stringCode == null || stringCode.Length == 0)
            {
                return(true);
            }
            if (stringCode.IndexOf("||") >= 0)
            {
                string[] separator = new string[]
                {
                    "||"
                };
                string[] array = stringCode.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length >= 2)
                {
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (FeatureMatrix.IsMatchServerCode(array[i]))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
            }
            stringCode = stringCode.Trim();
            if (stringCode[0] == '!')
            {
                return(!FeatureMatrix.IsMatchServerCode(stringCode.Substring(1)));
            }
            int num = 0;

            try
            {
                num = int.Parse(stringCode);
            }
            catch
            {
                Log <FeatureMatrix> .Logger.ErrorFormat("Not an Integer value ServerCode - {0}", stringCode);

                return(false);
            }
            return(num > 0 && FeatureMatrix.ServerCode == num);
        }
Ejemplo n.º 8
0
 public static string GetString(string featureName)
 {
     if (!FeatureMatrix.featureMatrixLoaded)
     {
         FeatureMatrix.LoadFeatureMatrix();
     }
     lock (FeatureMatrix.featureLock)
     {
         string result;
         if (FeatureMatrix.overrideMap.TryGetValue(featureName, out result))
         {
             return(result);
         }
         if (FeatureMatrix.featureMap.TryGetValue(featureName, out result))
         {
             return(result);
         }
     }
     return("");
 }
Ejemplo n.º 9
0
        public static int?GetNullableInt(string featureName)
        {
            string @string = FeatureMatrix.GetString(featureName);

            if (@string == null || @string == "")
            {
                return(null);
            }
            int?result;

            try
            {
                result = new int?(int.Parse(@string));
            }
            catch (FormatException)
            {
                Log <FeatureMatrix> .Logger.ErrorFormat("Not an Integer value - Feature {0}='{1}'", featureName, @string);

                result = null;
            }
            return(result);
        }
Ejemplo n.º 10
0
        private void ReportData()
        {
            if (!this.IsInitialized)
            {
                return;
            }
            List <object[]> list = this.GetReportData().ToList <object[]>();

            if (FeatureMatrix.IsEnable("ServiceReporter_ToDB"))
            {
                this.ReportDataToDB(list);
            }
            if (FeatureMatrix.IsEnable("ServiceReporter_ToCSV"))
            {
                this.ReportDataToCsv(list);
            }
            this.RowNumber += list.Count <object[]>();
            this.LogEntries.Clear();
            foreach (ServiceReporter.SubjectEntry subjectEntry in this.Subjects)
            {
                subjectEntry.StatHistory.Clear();
            }
        }
Ejemplo n.º 11
0
        private static bool LoadFeatureMatrix()
        {
            bool result;

            lock (FeatureMatrix.featureLock)
            {
                if (FeatureMatrix.featureMatrixLoaded)
                {
                    result = false;
                }
                else
                {
                    FeatureMatrix.gameCodeMap         = HeroesContentsLoader.GetGameCode();
                    FeatureMatrix.featureMap          = HeroesContentsLoader.GetFeatureMatrix(FeatureMatrix.LangTag);
                    FeatureMatrix.featureMatrixLoaded = true;
                    if (FeatureMatrix.GetString("OverrideSetting").Length > 0)
                    {
                        Dictionary <string, string> featureMatrix = HeroesContentsLoader.GetFeatureMatrix(FeatureMatrix.GetString("OverrideSetting"));
                        foreach (KeyValuePair <string, string> keyValuePair in featureMatrix)
                        {
                            string key = keyValuePair.Key;
                            if (key != "GameCode" && key != "CurrentVer" && key != "OverrideSetting")
                            {
                                FeatureMatrix.featureMap[key] = keyValuePair.Value;
                            }
                        }
                    }
                    if (ServiceCoreSettings.Default.NGM_Disable != "-1")
                    {
                        FeatureMatrix.overrideMap["NGM_disable"] = ServiceCoreSettings.Default.NGM_Disable;
                    }
                    result = true;
                }
            }
            return(result);
        }