private void WriteManifestInternal()

in Source/Tx.Bond/BinaryEventSource.cs [189:245]


        private void WriteManifestInternal(
            DateTime occurenceTime,
            DateTime receiveTime,
            string inputProtocol,
            string source,
            string manifestId,
            string manifestData)
        {
            // Maximum record size is 64K for both system and user data, so counting 88 bytes for system data here as well
            var maxPayloadSize = (MaxPayloadSize / 2) - (manifestId.Length + source.Length + inputProtocol.Length) * 2;

            if (maxPayloadSize <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            var occurenceFileTimeUtc = occurenceTime.ToFileTimeUtc();
            var receiveFileTimeUtc = receiveTime.ToFileTimeUtc();

            if (manifestData.Length <= maxPayloadSize)
            {
                this.WriteManifestPayload(
                    occurenceFileTimeUtc,
                    receiveFileTimeUtc,
                    inputProtocol,
                    source,
                    manifestId,
                    manifestData);
            }
            else
            {
                // User data for chunked event is 12 bytes greather than non-chunked event
                maxPayloadSize -= 12;

                List<string> chunks = new List<string>(manifestData.WholeChunks(maxPayloadSize));

                lock (this.writeChuckedManifestPayloadGuard)
                {
                    var packageId = unchecked(this.currentManifestPackageId++);
                    int i = 0;

                    foreach (string chunk in chunks)
                    {
                        this.WriteChunkedManifestPayload(
                            packageId,
                            occurenceFileTimeUtc,
                            receiveFileTimeUtc,
                            inputProtocol,
                            source,
                            manifestId,
                            chunks.Count,
                            i++,
                            chunk);
                    }
                }
            }
        }