Esempio n. 1
0
        /// <summary>
        ///     Deeply clone the object.
        /// </summary>
        /// <returns>
        ///     Cloned object.
        /// </returns>
        /// <exception cref="InvalidOperationException">Thrown when byte is not set</exception>
        public ISafeByte DeepClone()
        {
            EnsureByteIsSet();
            _memoryProtector.Unprotect(_encryptionKey);
            _memoryProtector.Unprotect(_encryptedByte);
            var clone = new SafeByte(_id, _realBytePosition, _encryptedByteLength, _encryptionKey, _encryptedByte,
                                     _encryptor, _fastRandom, _byteIdGenerator, _memoryProtector);

            _memoryProtector.Protect(_encryptionKey);
            _memoryProtector.Protect(_encryptedByte);
            return(clone);
        }
Esempio n. 2
0
        /// <inheritdoc cref="EnsureByteIsSet"/>
        /// <inheritdoc cref="DisposableBase.ThrowIfDisposed"/>
        public ISafeByte DeepClone()
        {
            EnsureByteIsSet();
            ThrowIfDisposed();
            var clone = new SafeByte(
                id: _id,
                realBytePosition: _realBytePosition,
                encryptedByteLength: _encryptedByteLength,
                encryptor: _encryptor,
                fastRandom: _fastRandom,
                byteIdGenerator: _byteIdGenerator,
                encryptedByte: _encryptedByte,
                encryptionKey: _encryptionKey);

            return(clone);
        }