예제 #1
0
        public KarmaSerializer(Stream stream, KarmaOptions options = null)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (!stream.CanWrite)
            {
                throw new ArgumentException("Can not write to stream.");
            }

            this.writer  = new KarmaWriter(stream);
            this.stream  = stream;
            this.options = options ?? new KarmaOptions();

            WriteHeader();
        }
예제 #2
0
        public KarmaDeserializer(Stream stream, KarmaOptions options = null)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (!stream.CanRead)
            {
                throw new ArgumentException("Stream can not be read.");
            }

            this.stream     = stream;
            this.reader     = new KarmaReader(stream);
            this.options    = options ?? new KarmaOptions();
            this.assemblies = AppDomain.CurrentDomain.GetAssemblies();

            ReadHeader();
        }