ATMLCommonLibrary.forms.ATMLOptionsForm.ProcessOption C# (CSharp) Method

ProcessOption() private method

private ProcessOption ( XmlElement parentElement, TreeNode parentTreeNode, PropertyOption>.Dictionary options ) : void
parentElement XmlElement
parentTreeNode TreeNode
options PropertyOption>.Dictionary
return void
        private void ProcessOption(XmlElement parentElement, TreeNode parentTreeNode, Dictionary<String, PropertyOption> options )
        {
            foreach (XmlNode child in parentElement.ChildNodes)
            {
                var element = child as XmlElement;
                if (element != null)
                {
                    if ("option".Equals(child.Name))
                    {
                        string name = element.GetAttribute("name");
                        var node = new TreeNode(name);
                        node.SelectedImageIndex =
                            node.ImageIndex = int.Parse(element.GetAttribute("imageId"));
                        if (parentTreeNode == null)
                            optionTree.Nodes.Add(node);
                        else
                            parentTreeNode.Nodes.Add(node);
                        PropertyOption option = null;
                        if (options.ContainsKey(name))
                            option = options[name];
                        else
                        {
                            option = new PropertyOption(name);
                            options.Add(name, option);
                        }
                        try
                        {
                            ProcessOption(element, node, option.Options);
                        }
                        catch (Exception)
                        {
                            int i = 0;
                        }

                    }
                    else if ("controls".Equals(child.Name))
                    {
                        var properties = new Dictionary<string, PropertyOption>();
                        foreach (XmlNode control in element.ChildNodes)
                        {
                            var xmlElement = control as XmlElement;
                            if (xmlElement != null)
                            {
                                string _label = xmlElement.GetAttribute("label");
                                string _name = xmlElement.GetAttribute("name");
                                string _default = xmlElement.GetAttribute("default");
                                string _class = xmlElement.GetAttribute("class");
                                string _description = xmlElement.GetAttribute("description");
                                string _category = xmlElement.GetAttribute("category");
                                object _value = ATMLContext.GetProperty(_name);

                                if (!string.IsNullOrEmpty(_class))
                                {
                                    if( _value == null )
                                        _value = "String".Equals(_class)
                                                ? _default
                                                : "double".Equals(_class)
                                                ? double.Parse(_default)
                                                : "int".Equals(_class)
                                                ? int.Parse(_default)
                                                : "Int32".Equals(_class)
                                                ? Int32.Parse(_default)
                                                : "Boolean".Equals(_class)
                                                ? "1"==_default
                                                : "Color".Equals(_class)
                                                ? ColorTranslator.FromHtml(_default)
                                                : Activator.CreateInstance(Type.GetType(_class));
                                    PropertyOption option = null;
                                    if (options.ContainsKey(_name))
                                        option = options[_name];
                                    else
                                    {
                                        option = new PropertyOption(_name);
                                        option.Description = _description;
                                        option.Category = _category;
                                        option.Label = _label;
                                        options.Add(_name, option);
                                    }
                                    option.Value = _value;
                                    properties.Add(_name, option);
                                }
                            }
                        }
                        if (parentTreeNode != null) parentTreeNode.Tag = properties;
                    }
                }
            }
        }