示例#1
0
        /// <summary>
        /// 创建 DomElement 实例
        /// </summary>
        /// <param name="name"></param>
        /// <param name="attributes"></param>
        public DomElement(string name, IDictionary <string, string> attributes)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            _name       = name;
            _attributes = new DomAttributeCollection(this);

            if (attributes != null)
            {
                attributes.ForAll(item => _attributes.Add(new DomAttribute(this, item.Key, item.Value)));
            }
        }
示例#2
0
        /// <summary>
        /// 创建 DomElement 实例
        /// </summary>
        /// <param name="name">元素名</param>
        /// <param name="attributes">属性</param>
        /// <param name="argumentCheck">是否进行参数检查</param>
        internal DomElement(string name, IDictionary <string, string> attributes, bool argumentCheck)
        {
            if (argumentCheck)
            {
                if (name == null)
                {
                    throw new ArgumentNullException("name");
                }

                if (!tagNameRegex.IsMatch(name))
                {
                    throw new FormatException("元素名称格式不正确");
                }
            }


            _name       = name;
            _attributes = new DomAttributeCollection(this);

            if (attributes != null)
            {
                attributes.ForAll(item => _attributes.Add(new DomAttribute(this, item.Key, item.Value)));
            }
        }