Example #1
0
		public void SendAttrsCreatedEvent()
		{
			foreach(AttrItem attr in this.attrs)
			{
				if (attr.m_bConnected == true)
					continue;

				ItemCreatedEventArgs endArgs = new ItemCreatedEventArgs();
				endArgs.item = attr;
				endArgs.bInitial = false;
				this.m_document.fireItemCreated(this.m_document,endArgs);

				attr.m_bConnected = true;
			}
		}
Example #2
0
		// 插入属性或者下级元素(按整数序号)
		internal void InsertAttrInternal(int nIndex,
			AttrItem newAttr,
			bool bAddObjTimestamp,
			bool bInitial)
		{
			newAttr.parent = this;

			this.attrs.Insert(nIndex,newAttr);

			if (bInitial == false)
			{
				string strError;
				int nRet = this.ProcessAttrNsURI(newAttr,
					bInitial,
					out strError);
				if (nRet == -1)
				{
					this.RemoveAttrInternal(newAttr,true);
					throw(new PrefixNotDefineException(strError));
				}
			}
			// 发ItemCreated()
			if (this.m_bConnected == true)
			{
				// ItemCreated事件
				ItemCreatedEventArgs endArgs = new ItemCreatedEventArgs();
				endArgs.item = newAttr;
				//endArgs.bInitial = false;
				this.m_document.fireItemCreated(this.m_document,endArgs);	
				newAttr.m_bConnected = true;
			}
			
			if (bAddObjTimestamp == true)
				this.m_objAttrsTimestamp ++;  
		}
Example #3
0
		// 插入属性或者下级元素(按整数序号)
        // Exception:
        //      可能会抛出PrefixNotDefineException异常
        internal void InsertChildInternal(int nIndex,
			Item newItem,
			bool bAddObjTimestamp,
			bool bInitial)
		{
			newItem.parent = this;
			this.children.Insert(nIndex,newItem);

			// 检查NamespaceURI是否存在
			if (newItem is ElementItem && bInitial == false)
			{
				string strError;
                int nRet = ((ElementItem)newItem).ProcessElementNsURI( // old : this
					bInitial,
					out strError);
				if (nRet == -1)
				{
					this.RemoveChildInternal(newItem,true);
					throw(new PrefixNotDefineException(strError));
				}
			}

			if (this.m_bConnected == true)
			{
                /*
				// end 调事件
                if (newItem is ElementItem)
                    FireItemCreatedTree((ElementItem)newItem);  // 递归触发事件
                else
                {*/

                    ItemCreatedEventArgs args = new ItemCreatedEventArgs();
                    args.item = newItem;
                    //args.bInitial = false;

                    newItem.m_bConnected = true;
                    this.m_document.fireItemCreated(this.m_document, args);
                //}

				if (newItem is ElementItem)
				{
					ElementItem elem = (ElementItem)newItem;
					elem.SendAttrsCreatedEvent();
				}
			}

			if (bAddObjTimestamp == true)
				this.m_objChildrenTimestmap ++;
		}
Example #4
0
        /*
        static void FireItemCreatedTree(ElementItem element)
        {
            ItemCreatedEventArgs endArgs = new ItemCreatedEventArgs();
            endArgs.item = element;
            element.m_bConnected = true;

            element.m_document.fireItemCreated(element.m_document, endArgs);

        
            // 递归
            for (int i = 0; i < element.children.Count; i++)
            {
                Item item = element.Children[i];
                if (!(item is ElementItem))
                    continue;
                FireItemCreatedTree((ElementItem)item);
            }
        
        }
        */


        // 追加属性节点
        public AttrItem AppendAttrInternal(AttrItem attr,
			bool bAddObjTimestamp,
			bool bInitial)
		{
			// 去掉原同名的属性节点
			AttrItem oldAttr = this.GetAttrItem(attr.Name);
			if (oldAttr != null)
				this.RemoveAttrInternal(oldAttr,false);  //可以和追加节点视作一次

			attr.parent = this;
			this.attrs.Add(attr);

			if (bInitial == false)
			{
				string strError;
				int nRet = this.ProcessAttrNsURI(attr,
					bInitial,
					out strError);
				if (nRet == -1)
				{
					this.RemoveAttrInternal(attr,true);
					throw(new PrefixNotDefineException(strError));
				}
			}

			// 发ItemCreated消息
			if (this.m_bConnected == true)
			{
				// ItemCreated事件
				ItemCreatedEventArgs endArgs = new ItemCreatedEventArgs();
				endArgs.item = attr;
				endArgs.bInitial = false;
				this.m_document.fireItemCreated(this.m_document,endArgs);	

				attr.m_bConnected = true;
			}

			if (bAddObjTimestamp == true)
				this.m_objAttrsTimestamp ++;

			return attr;
		}
Example #5
0
		// 追加子元素节点 
		// 最好判断一下即将插入的元素对象类型
		// 必须是ElementItem 或者 TextItem
		internal void AppendChildInternal(Item item,
			bool bAddObjTimestamp,
			bool bInitial)
		{
			Debug.Assert(item != null,"item参数不能为null");

			Debug.Assert(!(item is AttrItem),"item参数不能为AttrItem类型");
			
			item.parent = this;
			this.children.Add(item);

			// 检查NamespaceURI是否存在
			if (item is ElementItem
				&& bInitial == false)
			{
				ElementItem element = (ElementItem)item;
				string strError;
				int nRet = element.ProcessElementNsURI(bInitial,
					out strError);
				if (nRet == -1)
				{
					this.RemoveChildInternal(item,true);
					throw(new PrefixNotDefineException(strError));
				}
			}

			if (this.m_bConnected == true)
			{
                /*
                if (item is ElementItem)
                    FireItemCreatedTree((ElementItem)item);  // 递归触发事件
                else
                {*/
                    // end 调事件
                    ItemCreatedEventArgs endArgs = new ItemCreatedEventArgs();
                    endArgs.item = item;
                    item.m_bConnected = true;

                    this.m_document.fireItemCreated(this.m_document, endArgs);
                //}

				if (item is ElementItem)
				{
					ElementItem elem = (ElementItem)item;
					elem.SendAttrsCreatedEvent();  // 连带处理属性和儿子
				}
			}

			if (bAddObjTimestamp == true)
				this.m_objChildrenTimestmap ++;
		}
Example #6
0
		public void fireItemCreated(object sender,
			ItemCreatedEventArgs args)
		{
			if (ItemCreated != null)
			{
				ItemCreated(sender,args);
			}
		}