Opc.Ua.Com.Server.ComProxy.SaveConfiguredEndpoint C# (CSharp) Method

SaveConfiguredEndpoint() protected method

Saves the UA endpoint information associated the CLSID.
protected SaveConfiguredEndpoint ( System.Guid clsid, ConfiguredEndpoint endpoint ) : void
clsid System.Guid The CLSID used to activate the COM server.
endpoint ConfiguredEndpoint The endpoint.
return void
        protected void SaveConfiguredEndpoint(Guid clsid, ConfiguredEndpoint endpoint)
        {
            try
            {
                string relativePath = Utils.Format("%CommonApplicationData%\\OPC Foundation\\ComPseudoServers\\{0}.xml", clsid);
                string absolutePath = Utils.GetAbsoluteFilePath(relativePath, false, false, true);

                // oops - nothing found.
                if (absolutePath == null)
                {
                    absolutePath = Utils.GetAbsoluteFilePath(relativePath, true, false, true);
                }

                // open the file.
                FileStream ostrm = File.Open(absolutePath, FileMode.Create, FileAccess.ReadWrite);

                using (XmlTextWriter writer = new XmlTextWriter(ostrm, System.Text.Encoding.UTF8))
                {
                    DataContractSerializer serializer = new DataContractSerializer(typeof(ConfiguredEndpoint));
                    serializer.WriteObject(writer, endpoint);
                }
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error saving endpoint configuration for COM Proxy with CLSID={0}.", clsid);
            }
        }
        #endregion