Exemple #1
0
        /// <summary>
        /// Des the serialize.
        /// </summary>
        /// <typeparam name="T">typeparam</typeparam>
        /// <param name="stream">The stream.</param>
        /// <param name="salt">The salt.</param>
        /// <param name="password">The password.</param>
        /// <returns>returns</returns>
        /// <exception cref="ArgumentNullException"><paramref name="salt"/> is <see langword="null" />.see</exception>
        public T DeSerializeFromStream <T>(Stream stream, String salt, String password)
        {
            if (String.IsNullOrEmpty(salt))
            {
                throw new ArgumentNullException("salt");
            }
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }

            return(DeSerializeFromStream <T>(stream, XmlCryptography.GetCryptographyKey(salt, password)));
        }
Exemple #2
0
        /// <summary>
        /// Serializes the specified obj.
        /// </summary>
        /// <typeparam name="T">typeparam</typeparam>
        /// <param name="obj">The obj.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="salt">The salt.</param>
        /// <param name="password">The password.</param>
        /// <exception cref="ArgumentNullException"><paramref name="salt"/> is <see langword="null" />.see</exception>
        public void SerializeToStream <T>(T obj, Stream stream, String salt, String password)
        {
            if (String.IsNullOrEmpty(salt))
            {
                throw new ArgumentNullException("salt");
            }
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }

            SerializeToStream(obj, stream, XmlCryptography.GetCryptographyKey(salt, password));
        }
Exemple #3
0
        /// <summary>
        /// Des the serialize.
        /// </summary>
        /// <typeparam name="T">typeparam</typeparam>
        /// <param name="file">The file.</param>
        /// <param name="salt">The salt.</param>
        /// <param name="password">The password.</param>
        /// <param name="bufferSize">Size of the buffer.</param>
        /// <returns>returns</returns>
        /// <exception cref="ArgumentNullException"><paramref name="salt"/> is <see langword="null" />.see</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="cb " />is out of range. This parameter requires a non-negative number.</exception>
        public T DeSerializeFromFile <T>(String file, String salt, String password, Int32 bufferSize = BUFFER_SIZE)
        {
            if (String.IsNullOrEmpty(salt))
            {
                throw new ArgumentNullException("salt");
            }
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }

            return(DeSerializeFromFile <T>(file, XmlCryptography.GetCryptographyKey(salt, password), bufferSize));
        }
Exemple #4
0
        /// <summary>
        /// Serializes the specified obj.
        /// </summary>
        /// <typeparam name="T">typeparam</typeparam>
        /// <param name="obj">The obj.</param>
        /// <param name="file">The file.</param>
        /// <param name="salt">The salt.</param>
        /// <param name="password">The password.</param>
        /// <param name="bufferSize">Size of the buffer.</param>
        /// <exception cref="ArgumentNullException"><paramref name="password"/> is <see langword="null" />.see</exception>
        public void SerializeToFile <T>(T obj, String file, String salt, String password, Int32 bufferSize = BUFFER_SIZE)
        {
            if (String.IsNullOrEmpty(salt))
            {
                throw new ArgumentNullException("salt");
            }
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }

            SerializeToFile(obj, file, true, XmlCryptography.GetCryptographyKey(salt, password), bufferSize);
        }