Example #1
0
 public Opc.Server[] GetAvailableServers(Specification specification, string host, ConnectData connectData)
 {
     Opc.Server[] serverArray;
     lock (this)
     {
         NetworkCredential credential = (connectData != null) ? connectData.GetCredential(null, null) : null;
         this.m_server = (IOPCServerList2)Interop.CreateInstance(CLSID, host, credential);
         this.m_host   = host;
         try
         {
             ArrayList    list        = new ArrayList();
             Guid         guid        = new Guid(specification.ID);
             IOPCEnumGUID ppenumClsid = null;
             Guid[]       rgcatidImpl = new Guid[] { guid };
             this.m_server.EnumClassesOfCategories(1, rgcatidImpl, 0, null, out ppenumClsid);
             Guid[] guidArray = this.ReadClasses(ppenumClsid);
             Interop.ReleaseServer(ppenumClsid);
             ppenumClsid = null;
             foreach (Guid guid2 in guidArray)
             {
                 OpcCom.Factory factory = new OpcCom.Factory();
                 try
                 {
                     URL        url    = this.CreateUrl(specification, guid2);
                     Opc.Server server = null;
                     if (specification == Specification.COM_DA_30)
                     {
                         server = new Opc.Da.Server(factory, url);
                     }
                     else if (specification == Specification.COM_DA_20)
                     {
                         server = new Opc.Da.Server(factory, url);
                     }
                     else if (specification == Specification.COM_AE_10)
                     {
                         server = new Opc.Ae.Server(factory, url);
                     }
                     else if (specification == Specification.COM_HDA_10)
                     {
                         server = new Opc.Hda.Server(factory, url);
                     }
                     else if (specification == Specification.COM_DX_10)
                     {
                         server = new Opc.Dx.Server(factory, url);
                     }
                     list.Add(server);
                 }
                 catch (Exception)
                 {
                 }
             }
             serverArray = (Opc.Server[])list.ToArray(typeof(Opc.Server));
         }
         finally
         {
             Interop.ReleaseServer(this.m_server);
             this.m_server = null;
         }
     }
     return(serverArray);
 }
Example #2
0
 // Token: 0x06000004 RID: 4 RVA: 0x000020E4 File Offset: 0x000010E4
 public Opc.Server[] GetAvailableServers(Specification specification, string host, ConnectData connectData)
 {
     Opc.Server[] result;
     lock (this)
     {
         NetworkCredential credential = (connectData != null) ? connectData.GetCredential(null, null) : null;
         this.m_server = (IOPCServerList2)Interop.CreateInstance(ServerEnumerator.CLSID, host, credential);
         this.m_host   = host;
         try
         {
             ArrayList    arrayList    = new ArrayList();
             Guid         guid         = new Guid(specification.ID);
             IOPCEnumGUID iopcenumGUID = null;
             this.m_server.EnumClassesOfCategories(1, new Guid[]
             {
                 guid
             }, 0, null, out iopcenumGUID);
             Guid[] array = this.ReadClasses(iopcenumGUID);
             Interop.ReleaseServer(iopcenumGUID);
             iopcenumGUID = null;
             foreach (Guid clsid in array)
             {
                 Factory factory = new Factory();
                 try
                 {
                     URL        url   = this.CreateUrl(specification, clsid);
                     Opc.Server value = null;
                     if (specification == Specification.COM_DA_30)
                     {
                         value = new Opc.Da.Server(factory, url);
                     }
                     else if (specification == Specification.COM_DA_20)
                     {
                         value = new Opc.Da.Server(factory, url);
                     }
                     else if (specification == Specification.COM_AE_10)
                     {
                         value = new Opc.Ae.Server(factory, url);
                     }
                     else if (specification == Specification.COM_HDA_10)
                     {
                         value = new Opc.Hda.Server(factory, url);
                     }
                     else if (specification == Specification.COM_DX_10)
                     {
                         value = new Opc.Dx.Server(factory, url);
                     }
                     arrayList.Add(value);
                 }
                 catch (Exception)
                 {
                 }
             }
             result = (Opc.Server[])arrayList.ToArray(typeof(Opc.Server));
         }
         finally
         {
             Interop.ReleaseServer(this.m_server);
             this.m_server = null;
         }
     }
     return(result);
 }