Exemple #1
0
        private Option ParseOption(XElement root)
        {
            var option = new Option();

            option.Name         = CreateName(root, OptionElement.Attrs.Name);
            option.Id           = IdFactory.CreateId(option.Name);
            option.DisplayName  = ReplaceConstants(root.TryGetAttributeValue(OptionElement.Attrs.DisplayName, OptionElement.Attrs.Defaults.DisplayName));
            option.Description  = ReplaceConstants(root.TryGetAttributeValue(OptionElement.Attrs.Description, OptionElement.Attrs.Defaults.Description));
            option.DefaultValue = ReplaceConstants(root.TryGetAttributeValue <string>(OptionElement.Attrs.DefaultValue, null));
            option.ValueType    = root.TryGetAttributeValue(OptionElement.Attrs.ValueType, OptionElement.Attrs.Defaults.ValueType);
            var optionValue = _optionValueFactory.Create(option.ValueType);

            option.Behaviour = CreateBehaviour(root, optionValue);

            var defaultValueElement = root.Elements().FirstOrDefault(o => o.Name == OptionElement.Attrs.DefaultValue);

            if (defaultValueElement != null)
            {
                if (root.IsAttributeExists(OptionElement.Attrs.DefaultValue))
                {
                    _optionSetValidator.AddError($"Option '{option.Name}' has two defaultValue's.", root);
                }

                var dataElement = defaultValueElement.Elements().First();
                if (dataElement.NodeType != XmlNodeType.CDATA)
                {
                    _optionSetValidator.AddError("DefaultValue element doesn't contains CData.", dataElement);
                }

                option.DefaultValue = dataElement.Value.Trim();
            }

            return(option);
        }
Exemple #2
0
        private void ParseSuggestions(XElement root, IDictionary <string, Suggestion> suggestions)
        {
            root.Elements(SuggestionElement.ElementName)
            .ForEach(element =>
            {
                var suggestionElements = CreateSuggestion(element);

                if (suggestionElements.Count != 0)
                {
                    var suggestion = new Suggestion();

                    suggestion.Name = CreateName(element, SuggestionElement.Attrs.Name);
                    suggestion.Id   = IdFactory.CreateId(suggestion.Name);

                    foreach (var kv in suggestionElements)
                    {
                        suggestion.Params.Add(kv);
                    }

                    if (KeyIsUnique(suggestion.Name, suggestions))
                    {
                        suggestions[suggestion.Name] = suggestion;
                    }
                }
            });
        }
Exemple #3
0
        private Group ParseGroup(XElement root)
        {
            var group = new Group();

            group.Name        = CreateName(root, GroupElement.Attrs.Name);
            group.Id          = IdFactory.CreateId(group.Name);
            group.DisplayName = ReplaceConstants(root.TryGetAttributeValue(GroupElement.Attrs.DisplayName, GroupElement.Attrs.Defaults.DisplayName));
            group.Description = ReplaceConstants(root.TryGetAttributeValue(GroupElement.Attrs.Description, GroupElement.Attrs.Defaults.Description));
            ParseGroupOptions(root, group.GroupOptions);
            ParseGroups(root, group.Groups);

            return(group);
        }
Exemple #4
0
 protected Entity()
 {
     Id = IdFactory.CreateId();
 }