Opc.Ua.ServerTest.ServerTestConfiguration.Load C# (CSharp) Method

Load() public static method

Loads the configuration from the application configuration file.
public static Load ( XmlElementCollection extensions ) : ServerTestConfiguration
extensions System.Xml.XmlElementCollection
return ServerTestConfiguration
        public static ServerTestConfiguration Load(XmlElementCollection extensions)
        {
            if (extensions == null || extensions.Count == 0)
            {
                return new ServerTestConfiguration();
            }

            foreach (XmlElement element in extensions)
            {
                if (element.NamespaceURI != "http://opcfoundation.org/UA/SDK/ServerTest/Configuration.xsd")
                {
                    continue;
                }

			    XmlNodeReader reader = new XmlNodeReader(element);

                try
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(ServerTestConfiguration));
                    ServerTestConfiguration configuration = serializer.ReadObject(reader) as ServerTestConfiguration;
                    
                    if (configuration.Iterations <= 0)
                    {
                        configuration.Iterations = 1;
                    }

                    return configuration;
                }
                finally
                {
                    reader.Close();
                }
            }
                        
            return new ServerTestConfiguration();
        }
		#endregion

Same methods

ServerTestConfiguration::Load ( string filePath, ServerTestConfiguration masterConfiguration ) : ServerTestConfiguration

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Loads the configuration and initializes the form.
        /// </summary>
        public MainForm()
        {
            InitializeComponent();
            this.Icon = ClientUtils.GetAppIcon();

            m_configuration = GuiUtils.DoStartupChecks("Opc.Ua.ServerTestTool", ApplicationType.Client, null, true);

            if (m_configuration != null)
            {
                GuiUtils.OverrideUaTcpImplementation(m_configuration);
                GuiUtils.DisplayUaTcpImplementation(this, m_configuration);
            }

            m_configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            m_testConfiguration = ServerTestConfiguration.Load(m_configuration.Extensions);

            // allow UA servers to use the same certificate for HTTPS validation.
            ApplicationInstance.SetUaValidationForHttps(m_configuration.CertificateValidator);

            TestCasesCTRL.Initialize(m_testConfiguration);

            // get list of cached endpoints.
            m_endpoints = m_configuration.LoadCachedEndpoints(true);
            EndpointsCTRL.Initialize(m_endpoints, m_configuration);

            // create the test client.
            m_testClient = new ServerTestClient(m_configuration);

            m_testClient.ReportResult   += new EventHandler <ServerTestClient.ReportResultEventArgs>(TestClient_ReportTestResult);
            m_testClient.ReportProgress += new EventHandler <ServerTestClient.ReportProgressEventArgs>(TestClient_ReportTestProgress);
        }
All Usage Examples Of Opc.Ua.ServerTest.ServerTestConfiguration::Load