Beispiel #1
0
        internal static byte[] BuildDeviceNotificationBuffer(TcAdsStampHeader[] stampHeaders)
        {
            uint num = 0;

            TcAdsStampHeader[] headerArray = stampHeaders;
            int index = 0;

            while (index < headerArray.Length)
            {
                TcAdsStampHeader          header = headerArray[index];
                TcAdsNotificationSample[] notificationSamples = header.NotificationSamples;
                num += (uint)12;
                TcAdsNotificationSample[] sampleArray2 = notificationSamples;
                int num3 = 0;
                while (true)
                {
                    if (num3 >= sampleArray2.Length)
                    {
                        index++;
                        break;
                    }
                    TcAdsNotificationSample sample = sampleArray2[num3];
                    num = (num + 8) + sample.SampleSize;
                    num3++;
                }
            }
            byte[]       buffer = new byte[num];
            BinaryWriter writer = new BinaryWriter(new MemoryStream(buffer));

            foreach (TcAdsStampHeader header2 in stampHeaders)
            {
                header2.WriteToBuffer(writer);
            }
            return(buffer);
        }
Beispiel #2
0
        internal static TcAdsStampHeader[] ReadNotificationStampHeaders(byte[] amsData, uint numStampHeaders)
        {
            MemoryStream input  = new MemoryStream(amsData);
            BinaryReader reader = new BinaryReader(input);

            input.Position = 8L;
            TcAdsStampHeader[] headerArray = new TcAdsStampHeader[numStampHeaders];
            for (int i = 0; i < numStampHeaders; i++)
            {
                headerArray[i] = new TcAdsStampHeader(reader);
            }
            input.Close();
            return(headerArray);
        }