using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections.Specialized;

namespace TFSWrappers
{
    public class BuildTypeItemGroupItem
    {
        public BuildTypeItemGroupItem(XmlNode xmlNode)
        {
            this.xmlNode = xmlNode;
            this.childXmlNodeList = xmlNode.ChildNodes;
            childProperties = new NameValueCollection();
            foreach (XmlNode childXmlNode in childXmlNodeList)
            {
                childProperties.Add(childXmlNode.Name, childXmlNode.InnerText);
            }
        }

        public BuildTypeItemGroupItem(XmlDocument xmlDocument, XmlNamespaceManager xmlNamespaceManager,
            XmlNode itemGroupNode, string itemGroupName, string include)
        {
            xmlNode = xmlDocument.CreateNode(XmlNodeType.Element, itemGroupName, Constants.NamespaceUri);
            XmlAttribute xmlAttribute = xmlDocument.CreateAttribute(Constants.IncludeAttributeName);
            xmlAttribute.Value = include;
            itemGroupNode.AppendChild(xmlNode);
        }

        private XmlNode xmlNode;
        private XmlNodeList childXmlNodeList;

        public string Include
        {
            get 
            {
                return xmlNode.Attributes[Constants.IncludeAttributeName].Value;
            }
            set 
            { 
               xmlNode.Attributes[Constants.IncludeAttributeName].Value = value;
            }
        }

        private NameValueCollection childProperties;

        public NameValueCollection ChildProperties
        {
            get { return childProperties; }
        }
    }
}
