Пример #1
0
        public static Dictionary <string, OverlayVariableBaseModel> ProcessVariables(XmlNode vlNode, DirectoryInfo startDirectory)
        {
            Dictionary <string, OverlayVariableBaseModel> variableDictionary = new Dictionary <string, OverlayVariableBaseModel>();

            foreach (XmlNode vNode in vlNode.ChildNodes)
            {
                OverlayVariableBaseModel ov = null;
                switch (vNode.LocalName)
                {
                case "Counter":
                    ov = new OverlayCounterViewModel();
                    break;

                case "DropDown":
                    ov = new OverlayDropDownViewModel();
                    break;

                case "String":
                    ov = new OverlayStringViewModel();
                    break;

                case "ItemSelector":
                    ov = new OverlayItemSelectorViewModel();
                    break;
                }

                if (ov != null)
                {
                    try
                    {
                        ov.FromXML(vNode);
                    } catch (InvalidXMLValueException ex) {
                        MessageBox.Show(ex.Message);
                        throw new VariableParseException(VariableParseException.Reason.InvalidXML);
                    }

                    try
                    {
                        variableDictionary.Add(ov.Name, ov);
                    } catch (ArgumentException) {
                        if (ov.Name == null)
                        {
                            throw new VariableParseException(VariableParseException.Reason.NullVariable);
                        }
                        else
                        {
                            throw new VariableParseException(VariableParseException.Reason.DuplicateVariable);
                        }
                    }
                }
            }
            return(variableDictionary);
        }
        public static Dictionary<string, OverlayVariableBaseModel> ProcessVariables(XmlNode vlNode, DirectoryInfo startDirectory)
        {
            Dictionary<string, OverlayVariableBaseModel> variableDictionary = new Dictionary<string, OverlayVariableBaseModel>();

            foreach (XmlNode vNode in vlNode.ChildNodes)
            {
                OverlayVariableBaseModel ov = null;
                switch (vNode.LocalName)
                {
                    case "Counter":
                        ov = new OverlayCounterViewModel();
                        break;

                    case "DropDown":
                        ov = new OverlayDropDownViewModel();
                        break;

                    case "String":
                        ov = new OverlayStringViewModel();
                        break;

                    case "ItemSelector":
                        ov = new OverlayItemSelectorViewModel();
                        break;
                }

                if (ov != null)
                {
                    try
                    {
                        ov.FromXML(vNode);
                    } catch (InvalidXMLValueException ex) {
                        MessageBox.Show(ex.Message);
                        throw new VariableParseException(VariableParseException.Reason.InvalidXML);
                    }

                    try
                    {
                        variableDictionary.Add(ov.Name, ov);
                    } catch (ArgumentException) {
                        if (ov.Name == null)
                        {
                            throw new VariableParseException(VariableParseException.Reason.NullVariable);
                        } else {
                            throw new VariableParseException(VariableParseException.Reason.DuplicateVariable);
                        }
                    }
                }
            }
            return variableDictionary;
        }