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

namespace TFSWrappers
{
    public class BuildTypePropertyAttribute
    {
        public BuildTypePropertyAttribute(XmlDocument xmlDocument, XmlNamespaceManager xmlNamespaceManager,
            string NodeXPath, string attributeName)
        {
            xmlNode = xmlDocument.SelectSingleNode(NodeXPath, xmlNamespaceManager);
            exists = xmlNode != null;
            this.attributeName = attributeName;
        }

        private XmlNode xmlNode;

        private bool exists;

        public bool Exists
        {
            get { return exists; }
        }

        private string attributeName;

        public string Value
        {
            get 
            {
                if (exists)
                {
                    return xmlNode.Attributes[attributeName].Value;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if (exists)
                {
                    xmlNode.Attributes[attributeName].Value = value;
                }
            }
        }
    }
}
