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

LoadConfiguredEndpoint() protected method

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

                // oops - nothing found.
                if (absolutePath == null)
                {
                    return null;
                }

                // open the file.
                using (FileStream istrm = File.Open(absolutePath, FileMode.Open, FileAccess.Read))
                {
                    using (XmlTextReader reader = new XmlTextReader(istrm))
                    {
                        DataContractSerializer serializer = new DataContractSerializer(typeof(ConfiguredEndpoint));
                        return (ConfiguredEndpoint)serializer.ReadObject(reader, false);
                    }
                }
            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error loading endpoint configuration for COM Proxy with CLSID={0}.", clsid);
                return null;
            }
        }