protected override Stream Export(BufferManager bufferManager, int count)
        {
            lock (this.ThisLock)
            {
                BufferStream bufferStream = new BufferStream(bufferManager);

                // CreationTime
                if (this.CreationTime != DateTime.MinValue)
                {
                    ItemUtilities.Write(bufferStream, (byte)SerializeId.CreationTime, this.CreationTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", System.Globalization.DateTimeFormatInfo.InvariantInfo));
                }
                // ExchangeKey
                if (this.ExchangeKey != null)
                {
                    ItemUtilities.Write(bufferStream, (byte)SerializeId.ExchangeKey, this.ExchangeKey);
                }
                // ProtocolHash
                if (this.ProtocolHash != null)
                {
                    ItemUtilities.Write(bufferStream, (byte)SerializeId.ProtocolHash, this.ProtocolHash);
                }

                // Certificate
                if (this.Certificate != null)
                {
                    using (var stream = this.Certificate.Export(bufferManager))
                    {
                        ItemUtilities.Write(bufferStream, (byte)SerializeId.Certificate, stream);
                    }
                }

                bufferStream.Seek(0, SeekOrigin.Begin);
                return(bufferStream);
            }
        }
Exemple #2
0
        protected override Stream Export(BufferManager bufferManager, int count)
        {
            lock (this.ThisLock)
            {
                BufferStream bufferStream = new BufferStream(bufferManager);

                // KeyExchangeAlgorithm
                if (this.KeyExchangeAlgorithm != 0)
                {
                    ItemUtilities.Write(bufferStream, (byte)SerializeId.KeyExchangeAlgorithm, this.KeyExchangeAlgorithm.ToString());
                }
                // KeyDerivationAlgorithm
                if (this.KeyDerivationAlgorithm != 0)
                {
                    ItemUtilities.Write(bufferStream, (byte)SerializeId.KeyDerivationAlgorithm, this.KeyDerivationAlgorithm.ToString());
                }
                // CryptoAlgorithm
                if (this.CryptoAlgorithm != 0)
                {
                    ItemUtilities.Write(bufferStream, (byte)SerializeId.CryptoAlgorithm, this.CryptoAlgorithm.ToString());
                }
                // HashAlgorithm
                if (this.HashAlgorithm != 0)
                {
                    ItemUtilities.Write(bufferStream, (byte)SerializeId.HashAlgorithm, this.HashAlgorithm.ToString());
                }
                // SessionId
                if (this.SessionId != null)
                {
                    ItemUtilities.Write(bufferStream, (byte)SerializeId.SessionId, this.SessionId);
                }

                bufferStream.Seek(0, SeekOrigin.Begin);
                return(bufferStream);
            }
        }