Tx.Bond.BinaryEtwParser.ParseChunkedManifest C# (CSharp) Method

ParseChunkedManifest() private method

private ParseChunkedManifest ( Tx.Windows.EtwNativeEvent etwNativeEvent ) : EventManifest
etwNativeEvent Tx.Windows.EtwNativeEvent
return EventManifest
        private EventManifest ParseChunkedManifest(EtwNativeEvent etwNativeEvent)
        {
            uint packageId = etwNativeEvent.ReadUInt32();
            long occurenceFileTimeUtc = etwNativeEvent.ReadInt64();
            long receiveFileTimeUtc = etwNativeEvent.ReadInt64();
            string protocol = etwNativeEvent.ReadUnicodeString();
            string source = etwNativeEvent.ReadUnicodeString();
            string manifestId = etwNativeEvent.ReadUnicodeString();
            uint chunkCount = etwNativeEvent.ReadUInt32();
            uint currentChunkNumber = etwNativeEvent.ReadUInt32();
            string manifest = etwNativeEvent.ReadUnicodeString();

            if (chunkCount == 1)
            {
                this.manifestCache.Clear();

                return new EventManifest
                {
                    ActivityId = etwNativeEvent.ActivityId,
                    OccurenceFileTimeUtc = occurenceFileTimeUtc,
                    ReceiveFileTimeUtc = receiveFileTimeUtc,
                    Protocol = protocol,
                    Source = source,
                    ManifestId = manifestId,
                    Manifest = manifest
                };
            }
            else if (chunkCount > currentChunkNumber)
            {
                if (this.currentManifestPackageId != packageId || this.manifestCache.Count != currentChunkNumber)
                {
                    this.manifestCache.Clear();
                    this.currentManifestPackageId = packageId;
                }

                this.manifestCache.Add(manifest);

                if (chunkCount == (currentChunkNumber + 1))
                {
                    string payload = string.Join("", this.manifestCache.ToArray());
                    this.manifestCache.Clear();

                    return new EventManifest
                    {
                        ActivityId = etwNativeEvent.ActivityId,
                        OccurenceFileTimeUtc = occurenceFileTimeUtc,
                        ReceiveFileTimeUtc = receiveFileTimeUtc,
                        Protocol = protocol,
                        Source = source,
                        ManifestId = manifestId,
                        Manifest = payload,
                    };
                }
            }
            else
            {
                this.manifestCache.Clear();
            }

            return null;
        }