public Opc.Ae.Attribute[] QueryEventAttributes(int eventCategory) { lock (this) { if (m_server == null) { throw new NotConnectedException(); } int pdwCount = 0; IntPtr ppdwAttrIDs = IntPtr.Zero; IntPtr ppszAttrDescs = IntPtr.Zero; IntPtr ppvtAttrTypes = IntPtr.Zero; try { ((IOPCEventServer)m_server).QueryEventAttributes(eventCategory, out pdwCount, out ppdwAttrIDs, out ppszAttrDescs, out ppvtAttrTypes); } catch (Exception e) { throw OpcCom.Interop.CreateException("IOPCEventServer.QueryEventAttributes", e); } if (pdwCount == 0) { return(new Opc.Ae.Attribute[0]); } int[] int32s = OpcCom.Interop.GetInt32s(ref ppdwAttrIDs, pdwCount, deallocate: true); string[] unicodeStrings = OpcCom.Interop.GetUnicodeStrings(ref ppszAttrDescs, pdwCount, deallocate: true); short[] int16s = OpcCom.Interop.GetInt16s(ref ppvtAttrTypes, pdwCount, deallocate: true); Opc.Ae.Attribute[] array = new Opc.Ae.Attribute[pdwCount]; for (int i = 0; i < pdwCount; i++) { array[i] = new Opc.Ae.Attribute(); array[i].ID = int32s[i]; array[i].Name = unicodeStrings[i]; array[i].DataType = OpcCom.Interop.GetType((VarEnum)int16s[i]); } return(array); } }
public Opc.Ae.Attribute[] QueryEventAttributes(int eventCategory) { lock (this) { if (base.m_server == null) { throw new NotConnectedException(); } int pdwCount = 0; IntPtr zero = IntPtr.Zero; IntPtr ppszAttrDescs = IntPtr.Zero; IntPtr ppvtAttrTypes = IntPtr.Zero; try { ((IOPCEventServer) base.m_server).QueryEventAttributes(eventCategory, out pdwCount, out zero, out ppszAttrDescs, out ppvtAttrTypes); } catch (Exception exception) { throw OpcCom.Interop.CreateException("IOPCEventServer.QueryEventAttributes", exception); } if (pdwCount == 0) { return new Opc.Ae.Attribute[0]; } int[] numArray = OpcCom.Interop.GetInt32s(ref zero, pdwCount, true); string[] strArray = OpcCom.Interop.GetUnicodeStrings(ref ppszAttrDescs, pdwCount, true); short[] numArray2 = OpcCom.Interop.GetInt16s(ref ppvtAttrTypes, pdwCount, true); Opc.Ae.Attribute[] attributeArray = new Opc.Ae.Attribute[pdwCount]; for (int i = 0; i < pdwCount; i++) { attributeArray[i] = new Opc.Ae.Attribute(); attributeArray[i].ID = numArray[i]; attributeArray[i].Name = strArray[i]; attributeArray[i].DataType = OpcCom.Interop.GetType((VarEnum) numArray2[i]); } return attributeArray; } }