XMLDA.NET Reference
ListBuilder Class
Members  Example  See Also  Send Feedback
xmldanet Namespace : ListBuilder Class

Glossary Item Box

This class contains methods to handle ItemLists and build request list for XML-DA server calls. The definition list XML files are typically created with the ListBuilder Tool.
First the definition lists are loaded from an XML file that is on disk or embedded in the application EXE file. Then lists are extracted into objects required for the XML-DA server calls. Additional methods help writing dynamic data elements into the extracted list.

Object Model

ListBuilder Class

Syntax

Visual Basic (Usage)Copy Code
Dim instance As ListBuilder
C# 
public class ListBuilder 

Example

C#Copy Code
string serviceUrl = "http://tswinc.us/XMLDADemo/ts_sim/OpcDaGateway.asmx";
      ListBuilder embeddedList ;
      ListBuilder externalList ;


      private void ListWrite_Click(object sender, System.EventArgs e)
      {
         try
         {
            //----------- load the lists from an XML file in the EXE directory
            externalList = new ListBuilder();
            externalList.Load( "ItemList.xml" );
            xmldanet.DefinitionListInfo[] infoExt = externalList.QueryLists();
            //----------- load the lists from an embedded XML file
            embeddedList = new ListBuilder();
            embeddedList.LoadEmbedded( "ItemList.xml" );
            xmldanet.DefinitionListInfo[] infoEmb = externalList.QueryLists();
         }
         catch( Exception ex )
         {
            MessageBox.Show( ex.Message, "Exception at Load Definitions" );
            Application.Exit();
         }

         //----------- get the list for a write server call with two items
         WriteRequestItemList wril = embeddedList.GetWriteItemList( "Write2" );
         if( wril == null )
         {
            MessageBox.Show( "List not found in definition file", "Error at get list" );
            return ;
         }

         //----------- complete the write request list with current values
         embeddedList.SetWriteValue( wril, "Lo", 200, null );
         embeddedList.SetWriteValue( wril, "Hi", 300, null );
         
         //----------- execute the service write call
         try
         {
            XmlServer Srv = new XmlServer( serviceUrl );
            ReplyBase reply ;
            RequestOptions options = new RequestOptions();
            options.ReturnErrorText = true ;
            options.ReturnItemName = true ;
            ReplyItemList rslt ;
            OPCError[] err ;
            reply = Srv.Write( options, wril, true, out rslt, out err );
            if( (err != null) && (err.Length>0) )
               MessageBox.Show( err[0].Text, "Error at Write" );
         }
         catch( Exception ex )
         {
            MessageBox.Show( ex.Message, "Exception in Write" );
         }
      }
Visual BasicCopy Code
Dim serviceUrl As String = "http://tswinc.us/XMLDADemo/ts_sim/OpcDaGateway.asmx"
   Dim embeddedList As ListBuilder
   Dim externalList As ListBuilder

   Private Sub LoadLists_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadLists.Click
      Try
         '----------- load the lists from an XML file in the EXE directory
         externalList = New ListBuilder
         externalList.Load("ItemList.xml")
         Dim infoExt As DefinitionListInfo() = externalList.QueryLists()

         '----------- load the lists from an embedded XML file
         embeddedList = New ListBuilder
         embeddedList.LoadEmbedded("ItemList.xml")
         Dim infoEmb As DefinitionListInfo() = externalList.QueryLists()
      Catch ex As Exception
         MessageBox.Show(ex.Message, "Exception at Load Definitions")
         Application.Exit()
      End Try

      '----------- get the list for a write server call with two items
      Dim wril As WriteRequestItemList = embeddedList.GetWriteItemList("Write2")
      If wril Is Nothing Then
         MessageBox.Show("List not found in definition file", "Error at get list")
         Return
      End If

      '----------- complete the write request list with current values
      embeddedList.SetWriteValue(wril, "Lo", 200, Nothing)
      embeddedList.SetWriteValue(wril, "Hi", 300, Nothing)

      '----------- execute the service write call
      Try
         Dim Srv As XmlServer = New XmlServer(serviceUrl)
         Dim reply As ReplyBase
         Dim options As RequestOptions = New RequestOptions
         options.ReturnErrorText = True
         options.ReturnItemName = True
         Dim rslt As ReplyItemList
         Dim err As OPCError()
         reply = Srv.Write(options, wril, True, rslt, err)
         If Not err Is Nothing And err.Length > 0 Then
            MessageBox.Show(err(0).Text, "Error at Write")
         End If
      Catch ex As Exception
         MessageBox.Show(ex.Message, "Exception in Write")
      End Try

   End Sub

Inheritance Hierarchy

System.Object
   xmldanet.ListBuilder

Requirements

Target Platforms: Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows 7, Windows Server 2008 family

See Also

© 2002-2012 Advosol Inc. All Rights Reserved.