// Token: 0x060000CC RID: 204 RVA: 0x000097C4 File Offset: 0x000087C4 public virtual void Initialize(URL url, ConnectData connectData) { if (url == null) { throw new ArgumentNullException("url"); } lock (this) { if (this.m_url == null || !this.m_url.Equals(url)) { if (this.m_server != null) { this.Uninitialize(); } this.m_server = (IOPCCommon)Factory.Connect(url, connectData); } this.m_url = (URL)url.Clone(); } }
//====================================================================== // IFactory /// <summary> /// Creates a new instance of the server. /// </summary> public override Opc.IServer CreateInstance(Opc.URL url, Opc.ConnectData connectData) { object comServer = Factory.Connect(url, connectData); if (comServer == null) { return(null); } OpcCom.Server server = null; System.Type interfaceType = null; try { // DA if (url.Scheme == Opc.UrlScheme.DA) { // Verify that it is a DA server. if (!typeof(OpcRcw.Da.IOPCServer).IsInstanceOfType(comServer)) { interfaceType = typeof(OpcRcw.Da.IOPCServer); throw new NotSupportedException(); } // DA 3.00 if (typeof(OpcRcw.Da.IOPCBrowse).IsInstanceOfType(comServer) && typeof(OpcRcw.Da.IOPCItemIO).IsInstanceOfType(comServer)) { server = new OpcCom.Da.Server(url, comServer); } // DA 2.XX else if (typeof(OpcRcw.Da.IOPCItemProperties).IsInstanceOfType(comServer)) { server = new OpcCom.Da20.Server(url, comServer); } else { interfaceType = typeof(OpcRcw.Da.IOPCItemProperties); throw new NotSupportedException(); } } // AE else if (url.Scheme == Opc.UrlScheme.AE) { // Verify that it is a AE server. if (!typeof(OpcRcw.Ae.IOPCEventServer).IsInstanceOfType(comServer)) { interfaceType = typeof(OpcRcw.Ae.IOPCEventServer); throw new NotSupportedException(); } server = new OpcCom.Ae.Server(url, comServer); } // HDA else if (url.Scheme == Opc.UrlScheme.HDA) { // Verify that it is a HDA server. if (!typeof(OpcRcw.Hda.IOPCHDA_Server).IsInstanceOfType(comServer)) { interfaceType = typeof(OpcRcw.Hda.IOPCHDA_Server); throw new NotSupportedException(); } server = new OpcCom.Hda.Server(url, comServer); } // DX else if (url.Scheme == Opc.UrlScheme.DX) { // Verify that it is a DX server. if (!typeof(OpcRcw.Dx.IOPCConfiguration).IsInstanceOfType(comServer)) { interfaceType = typeof(OpcRcw.Dx.IOPCConfiguration); throw new NotSupportedException(); } server = new OpcCom.Dx.Server(url, comServer); } // All other specifications not supported yet. else { throw new NotSupportedException(String.Format("The URL scheme '{0}' is not supported.", url.Scheme)); } } catch (NotSupportedException e) { OpcCom.Interop.ReleaseServer(server); server = null; if (interfaceType != null) { StringBuilder message = new StringBuilder(); message.AppendFormat("The COM server does not support the interface "); message.AppendFormat("'{0}'.", interfaceType.FullName); message.Append("\r\n\r\nThis problem could be caused by:\r\n"); message.Append("- incorrectly installed proxy/stubs.\r\n"); message.Append("- problems with the DCOM security settings.\r\n"); message.Append("- a personal firewall (sometimes activated by default).\r\n"); throw new NotSupportedException(message.ToString()); } throw e; } catch (Exception e) { OpcCom.Interop.ReleaseServer(server); server = null; throw e; } // initialize the wrapper object. if (server != null) { server.Initialize(url, connectData); } return(server); }