Ejemplo n.º 1
0
        /// <summary>
        /// Reads value by key
        /// </summary>
        public string Read(string key)
        {
            if (key == null)
            {
                return(null);
            }

            foreach (string variant in GetAllKeyVariants(key))
            {
                if (FlatArrays.IsArrayLength(variant, k => Environment.GetEnvironmentVariable(k), out int length))
                {
                    return(length.ToString());
                }

                if (FlatArrays.IsArrayElement(variant, k => Environment.GetEnvironmentVariable(k), out string element))
                {
                    return(element);
                }

                string value = Environment.GetEnvironmentVariable(variant);
                if (value != null)
                {
                    return(value);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        public string Read(string key)
        {
            if (FlatArrays.IsArrayLength(key, k => _iniFile[k], out int length))
            {
                return(length.ToString());
            }

            if (FlatArrays.IsArrayElement(key, k => _iniFile[k], out string element))
            {
                return(element);
            }

            return(_iniFile[key]);
        }
        public string Read(string key)
        {
            if (key == null)
            {
                return(null);
            }

            if (FlatArrays.IsArrayLength(key, k => GetRawValue(k), out int length))
            {
                return(length.ToString());
            }

            if (FlatArrays.IsArrayElement(key, k => GetRawValue(k), out string element))
            {
                return(element);
            }

            return(GetRawValue(key));
        }
Ejemplo n.º 4
0
        public string Read(string key)
        {
            if (key == null)
            {
                return(null);
            }

            if (FlatArrays.IsArrayLength(key, k => _container.GetValueOrDefault(k), out int length))
            {
                return(length.ToString());
            }

            if (FlatArrays.IsArrayElement(key, k => _container.GetValueOrDefault(k), out string element))
            {
                return(element);
            }

            return(_container.GetValueOrDefault(key));
        }
Ejemplo n.º 5
0
        public string Read(string key)
        {
            if (key == null)
            {
                return(null);
            }

            if (FlatArrays.IsArrayLength(key, k => _nameToValue.GetValueOrDefaultInternal(k), out int length))
            {
                return(length.ToString());
            }

            if (FlatArrays.IsArrayElement(key, k => _nameToValue.GetValueOrDefaultInternal(k), out string element))
            {
                return(element);
            }

            string value;

            _nameToValue.TryGetValue(key, out value);
            return(value);
        }