Ejemplo n.º 1
0
        /// <summary>
        /// Create new JSON schema using given settings
        /// </summary>
        /// <param name="configuration">Text encoding, ignore null...</param>
        public JSONSchema(JSONConfiguration configuration)
        {
            var writerDefinition = new WriterDefinition <TEntity>();
            var readerDefinition = new ReaderDefinition <TEntity>();

            this.configuration     = configuration;
            this.decoderConverter  = new DecoderConverter();
            this.encoderConverter  = new EncoderConverter();
            this.decoderDescriptor = new TreeDecoderDescriptor <ReaderState, JSONValue, int, TEntity>(this.decoderConverter, readerDefinition);
            this.encoderDescriptor = new TreeEncoderDescriptor <WriterState, JSONValue, TEntity>(this.encoderConverter, writerDefinition);
        }
Ejemplo n.º 2
0
        public ProtobufSchema(TextReader proto, string messageName, ProtobufConfiguration configuration)
        {
            var bindings         = Parser.Parse(proto).Resolve(messageName);
            var decoderConverter = new DecoderConverter();
            var encoderConverter = new EncoderConverter();
            var reader           = new ProtobufReaderDefinition <TEntity>(bindings, configuration.RejectUnknown);
            var writer           = new ProtobufWriterDefinition <TEntity>(bindings);

            this.decoderConverter  = decoderConverter;
            this.decoderDescriptor =
                new TreeDecoderDescriptor <ReaderState, ProtobufValue, int, TEntity>(decoderConverter, reader);

            this.encoderConverter  = encoderConverter;
            this.encoderDescriptor =
                new TreeEncoderDescriptor <WriterState, ProtobufValue, TEntity>(encoderConverter, writer);
        }
Ejemplo n.º 3
0
        public RawProtobufSchema(RawProtobufConfiguration configuration)
        {
            var decoderConverter = new RawProtobufDecoderConverter();
            var encoderConverter = new RawProtobufEncoderConverter();
            var readerDefinition = new ReaderDefinition <TEntity>();
            var writerDefinition = new WriterDefinition <TEntity>();

            this.configuration     = configuration;
            this.decoderConverter  = decoderConverter;
            this.decoderDescriptor =
                new TreeDecoderDescriptor <ReaderState, RawProtobufValue, char, TEntity>(decoderConverter,
                                                                                         readerDefinition);
            this.encoderConverter  = encoderConverter;
            this.encoderDescriptor =
                new TreeEncoderDescriptor <WriterState, RawProtobufValue, TEntity>(encoderConverter,
                                                                                   writerDefinition);
        }