CodeImp.Gluon.Configuration.CheckSetting C# (CSharp) Метод

CheckSetting() приватный Метод

private CheckSetting ( IDictionary dic, string setting, string pathseperator ) : bool
dic IDictionary
setting string
pathseperator string
Результат bool
        private bool CheckSetting(IDictionary dic, string setting, string pathseperator)
        {
            IDictionary cs = null;

            // Split the path in an array
            string[] keys = setting.Split(pathseperator.ToCharArray());

            // Get the root item
            object item = dic;

            // Go for each item
            for(int i = 0; i < keys.Length; i++)
            {
                // Check if the current item is of ConfigStruct type
                if(item is IDictionary)
                {
                    // Check if the key is valid
                    if(ValidateKey(null, keys[i].Trim(), "", -1) == true)
                    {
                        // Cast to ConfigStruct
                        cs = (IDictionary)item;

                        // Check if the requested item exists
                        if(cs.Contains(keys[i]) == true)
                        {
                            // Set the item to the next item
                            item = cs[keys[i]];
                        }
                        else
                        {
                            // Key not found
                            return false;
                        }
                    }
                    else
                    {
                        // Invalid key in path
                        return false;
                    }
                }
                else
                {
                    // Unable to go any further
                    return false;
                }
            }

            // Return result
            return true;
        }