Ejemplo n.º 1
0
        public UiNode(XomNode node, string name)
        {
            _children = new ObservableCollection<UiNode>();
            _xomNode = node;
            _baseName = name;
            IsExpanded = true;

            var attributes = _xomNode.Attributes;
            var type = XomAttributeTypeGenerator.GenerateType(attributes);
            var instance = Activator.CreateInstance(type);
            AttributeData = instance;

            UpdateNodeName();
        }
Ejemplo n.º 2
0
        private XomNode CreateNodesForType(Type type, ICollection<XomNode> foundNodes, bool isRoot = false)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            type = GetInnerType(type);

            var node = foundNodes.FirstOrDefault(x => x.Type == type);
            if (node != null)
                return node;

            node = new XomNode
            {
                Type = type,
                IsRoot =  isRoot,
                Attributes = GetAttributesForType(type)
            };

            foundNodes.Add(node);

            var children = type.GetProperties()
                               .Where(PropertyIsChildElement)
                               .ToArray();

            var childNodes = new List<XomNodeChild>();
            foreach (var child in children)
            {
                childNodes.Add(new XomNodeChild
                {
                    PropertyName = child.Name,
                    IsXmlArray = child.CustomAttributes.Any(x => x.AttributeType == typeof(XmlArrayAttribute)),
                    IsCollection = typeof(IEnumerable).IsAssignableFrom(child.PropertyType),
                    AvailableNodes = CreateAvailableNodesForProperty(child, foundNodes)
                });
            }

            node.Children = childNodes;
            return node;
        }
Ejemplo n.º 3
0
 public void CreateChild(XomNode xomNode, string name)
 {
     var newNode = new UiNode(xomNode, name);
     _children.Add(newNode);
 }