Beispiel #1
0
        public void JsonSchemaBuilder_ClassOfGuidWriterSchema()
        {
            var settings = new AvroSerializerSettings {
                Resolver = new AvroDataContractResolver(false)
            };
            IAvroSerializer <ClassOfGuid> serializer = AvroSerializer.Create <ClassOfGuid>(settings);
            string writerSchema = serializer.WriterSchema.ToString();

            AvroSerializer.CreateDeserializerOnly <ClassOfGuid>(writerSchema, settings);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StreamReader{T}"/> class for static types.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="leaveOpen">If set to <c>true</c> leaves the input stream open.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="codecFactory">The codec factory.</param>
        public StreamReader(Stream stream, bool leaveOpen, AvroSerializerSettings settings, CodecFactory codecFactory)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (codecFactory == null)
            {
                throw new ArgumentNullException("codecFactory");
            }

            this.stream     = stream;
            this.decoder    = new BinaryDecoder(stream, leaveOpen);
            this.header     = ObjectContainerHeader.Read(this.decoder);
            this.codec      = codecFactory.Create(this.header.CodecName);
            this.serializer = AvroSerializer.CreateDeserializerOnly <T>(this.header.Schema, settings);
        }