Beispiel #1
0
        public static string[] TryGetParamsByNameFromSubKey(string inKeyName, IKey inKey, ILogPrinter inLogger, bool inSubKeyMustBe, params int[] inParamCounts)
        {
            IKey sub_key = inKey.FindChildByName(inKeyName, StringComparison.InvariantCultureIgnoreCase);

            if (sub_key == null)
            {
                if (inSubKeyMustBe)
                {
                    inLogger.LogError(string.Format("Can't find subkey by name. Key [{0}] must have subkey {1}!", inKey.GetPath(), inKeyName));
                }
                return(null);
            }

            int value_count = sub_key.GetValuesCount();

            if (!inParamCounts.ContainsCheck(value_count))
            {
                string counts = inParamCounts.ToString(", ");
                inLogger.LogError(string.Format("Subkey [{0}] must have [{1}] counts of values, but was found {2}", sub_key.GetPath(), counts, value_count));
                return(null);
            }

            var a = new string[value_count];

            for (int i = 0; i < value_count; i++)
            {
                a[i] = sub_key.GetValueAsString(i);
            }

            return(a);
        }