コード例 #1
0
		} //	end ctr


		//-
		#endregion

		#region //	Public Methods
		//------------------------

		/// <summary>
		///  Adds a namespace element as child to a namespace element
		/// </summary>
		/// <param name="aChild">Child to be added</param>
		/// <returns>
		/// true	- Child successfully added
		/// false	- Child was not added
		/// </returns>
		/// <include
		///		file='TBNS.doc.xml'
		///		path='//class[@name="AeAddressSpaceElement"]/
		///		method[@name="AddChild"]/doc/*'
		///	/>
		public override bool AddChild(AddressSpaceElement aChild)
		{
			if (!HasChildren)
			{
				Application.Instance.Trace(
					EnumTraceLevel.WRN, EnumTraceGroup.OPCSERVER,
					"AeAddressSpaceElement.AddChild", "this element does not allow childred");
				return false;
			} //	end if

			AeAddressSpaceElement child = aChild as AeAddressSpaceElement;
			if (child == null)
			{
				Application.Instance.Trace(
					EnumTraceLevel.WRN, EnumTraceGroup.OPCSERVER,
					"AeAddressSpaceElement.AddChild", "Invalid child provided");
				return false;
			} //	end if

			//	only add the child if no handle assigned
			if (child.ObjectHandle == 0)
			{
				//	Prepare for the add addressSpace element call
				OTSAddressSpaceElementData data = new OTSAddressSpaceElementData();

				data.m_name = Marshal.StringToCoTaskMemUni(child.Name);
				data.m_itemID = Marshal.StringToCoTaskMemUni(
					Name + Application.Instance.AddressSpaceDelimiter + child.Name);

				data.m_hasChildren = Convert.ToByte(child.HasChildren);
				data.m_isBrowsable = Convert.ToByte(child.IsBrowsable);
				data.m_elementType = (byte) EnumAddressSpaceElementType.AE;
				data.m_userData = child.UserData;

				Application.Instance.AeAddressSpaceRoot.AddElementToArray(child);

				int result = OTBFunctions.OTSAddAddressSpaceElement(m_objectHandle, data, out child.m_objectHandle);

				Marshal.FreeCoTaskMem(data.m_name);
				Marshal.FreeCoTaskMem(data.m_itemID);

				if (!ResultCode.SUCCEEDED(result))
				{
					result = Application.Instance.AeAddressSpaceRoot.RemoveElementFromArray(child);
					System.Diagnostics.Debug.Assert(ResultCode.SUCCEEDED(result),
					                                "RemoveElementFromArray has failed");
					return false;
				} //	end if
			}
			else
			{
				Application.Instance.AeAddressSpaceRoot.AddElementToArray(child);
			} //	end if ... else

			return base.AddChild(aChild);
		} //	end AddChild
コード例 #2
0
		} //	end QueryAddressSpaceElementChildren


		/// <summary>
		/// retireves the conditions strings for a specified <see cref="AeAddressSpaceElement"/>
		/// </summary>
		/// <include
		///		file='TBNS.doc.xml'
		///			path='//class[@name="AeAddressSpaceRoot"]/
		///			method[@name="QueryConditions"]/doc/*'
		///	/>
		public virtual int QueryConditions(
			uint anUserData,
			string aSourcePath,
			out string[] aConditionNames)
		{
			AeAddressSpaceElement element = (AeAddressSpaceElement) GetElementFromArray(anUserData);

			if (element != null)
			{
				return element.QueryConditions(aSourcePath, out aConditionNames);
			}
			else
			{
				aConditionNames = null;
				return (int) EnumResultCode.S_FALSE;
			} //	end if ... else
		} //	end QueryConditions
コード例 #3
0
		} //	end AddChild


		/// <summary>
		/// Removes Child and its children if there are some
		/// </summary>
		/// <param name="aChild">AddressSpaceElement to be removed</param>
		/// <returns>
		/// true	- Child removed
		/// false	- Child was not removed
		/// </returns>
		/// <include
		///		file='TBNS.doc.xml'
		///			path='//class[@name="AeAddressSpaceElement"]/
		///			method[@name="RemoveChild"]/doc/*'
		///	/>
		public override bool RemoveChild(AddressSpaceElement aChild)
		{
			AeAddressSpaceElement child = aChild as AeAddressSpaceElement;

			if (child == null)
			{
				Application.Instance.Trace(EnumTraceLevel.WRN, EnumTraceGroup.OPCSERVER,
				                           "AeAddressSpaceElement.RemoveChild", "Invalid child provided");
				return false;
			} //	end if

			if (child.HasChildren)
			{
				//	Remove the clildren of the child
				ArrayList otherChildren = child.GetChildren();

				foreach (AddressSpaceElement element in otherChildren)
				{
					child.RemoveChild(element);
				} //	end for
			} //	end if

			int result = OTBFunctions.OTSRemoveAddressSpaceElement(child.ObjectHandle);
			if (!ResultCode.SUCCEEDED(result))
			{
				Application.Instance.Trace(EnumTraceLevel.WRN, EnumTraceGroup.OPCSERVER,
				                           "AeAddressSpaceElement.RemoveChild",
				                           "OTSRemoveAddressSpaceElement has failed with code" + result.ToString());
				return false;
			} //	end if

			result = Application.Instance.AeAddressSpaceRoot.RemoveElementFromArray(child);
			if (!ResultCode.SUCCEEDED(result))
			{
				Application.Instance.Trace(EnumTraceLevel.WRN, EnumTraceGroup.OPCSERVER,
				                           "AeAddressSpaceElement.RemoveChild",
				                           "OTSRemoveAddressSpaceElement has failed with code" + result.ToString());
				return false;
			} //	end if

			return base.RemoveChild(aChild);
		} //	end RemoveChild