Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of <see cref="VowpalWabbitJsonBuilder"/>.
        /// </summary>
        public VowpalWabbitJsonBuilder(VowpalWabbitJsonSerializer serializer, IVowpalWabbitExamplePool vwPool, VowpalWabbitDefaultMarshaller defaultMarshaller, JsonSerializer jsonSerializer, int multiIndex = -1)
        {
            Contract.Requires(serializer != null);
            Contract.Requires(vw != null);
            Contract.Requires(defaultMarshaller != null);
            Contract.Requires(jsonSerializer != null);

            this.extensionState = new VowpalWabbitJsonParseState
            {
                JsonBuilder = this,
                VW          = vwPool.Native,
                MultiIndex  = multiIndex
            };

            this.namespaceStrings = new List <string>();
            this.foundMulti       = false;
            if (serializer != null)
            {
                this.referenceResolver = serializer.ReferenceResolver;
            }
            this.serializer        = serializer;
            this.vw                = vwPool.Native;
            this.defaultMarshaller = defaultMarshaller;
            this.jsonSerializer    = jsonSerializer;

            this.DefaultNamespaceContext = new VowpalWabbitMarshalContext(this.vw);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VowpalWabbitJson"/> class.
        /// </summary>
        /// <param name="vw">The VW native instance.</param>
        public VowpalWabbitJsonSerializer(IVowpalWabbitExamplePool vwPool, VowpalWabbitJsonReferenceResolver referenceResolver = null)
        {
            Contract.Requires(vwPool != null);

            this.vwPool            = vwPool;
            this.referenceResolver = referenceResolver;
            this.defaultMarshaller = VowpalWabbitDefaultMarshaller.Instance;
            this.jsonSerializer    = new JsonSerializer();

            this.ExampleBuilder = new VowpalWabbitJsonBuilder(this, this.vwPool, this.defaultMarshaller, this.jsonSerializer);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VowpalWabbitJson"/> class.
        /// </summary>
        /// <param name="vw">The VW native instance.</param>
        public VowpalWabbitJsonSerializer(IVowpalWabbitExamplePool vwPool, VowpalWabbitJsonReferenceResolver referenceResolver = null)
        {
            Contract.Requires(vwPool != null);

            this.vwPool = vwPool;
            this.referenceResolver = referenceResolver;
            this.defaultMarshaller = VowpalWabbitDefaultMarshaller.Instance;
            this.jsonSerializer = new JsonSerializer();

            this.ExampleBuilder = new VowpalWabbitJsonBuilder(this, this.vwPool, this.defaultMarshaller, this.jsonSerializer);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VowpalWabbitJson"/> class.
        /// </summary>
        /// <param name="vwPool">The VW native instance.</param>
        /// <param name="referenceResolver">An optional reference resolver.</param>
        public VowpalWabbitJsonSerializer(IVowpalWabbitExamplePool vwPool, VowpalWabbitJsonReferenceResolver referenceResolver = null)
        {
            Contract.Requires(vwPool != null);

            this.extensions = new List <VowpalWabbitJsonExtension> {
                this.HandleMultiProperty
            };
            this.jsonSerializer = new JsonSerializer();

            this.vwPool            = vwPool;
            this.referenceResolver = referenceResolver;

            this.ExampleBuilder = new VowpalWabbitJsonBuilder(this, this.vwPool, VowpalWabbitDefaultMarshaller.Instance, this.jsonSerializer);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of <see cref="VowpalWabbitJsonBuilder"/>.
        /// </summary>
        public VowpalWabbitJsonBuilder(VowpalWabbitJsonSerializer serializer, IVowpalWabbitExamplePool vwPool, VowpalWabbitDefaultMarshaller defaultMarshaller, JsonSerializer jsonSerializer)
        {
            Contract.Requires(serializer != null);
            Contract.Requires(vw != null);
            Contract.Requires(defaultMarshaller != null);
            Contract.Requires(jsonSerializer != null);

            this.namespaceStrings  = new List <string>();
            this.referenceResolver = serializer.ReferenceResolver;
            this.serializer        = serializer;
            this.vw = vwPool.Native;
            this.defaultMarshaller = defaultMarshaller;
            this.jsonSerializer    = jsonSerializer;

            this.DefaultNamespaceContext = new VowpalWabbitMarshalContext(this.vw);
        }
        /// <summary>
        /// Initializes a new instance of <see cref="VowpalWabbitJsonBuilder"/>.
        /// </summary>
        public VowpalWabbitJsonBuilder(VowpalWabbitJsonSerializer serializer, IVowpalWabbitExamplePool vwPool, VowpalWabbitDefaultMarshaller defaultMarshaller, JsonSerializer jsonSerializer)
        {
            Contract.Requires(serializer != null);
            Contract.Requires(vw != null);
            Contract.Requires(defaultMarshaller != null);
            Contract.Requires(jsonSerializer != null);

            this.namespaceStrings = new List<string>();
            this.foundMulti = false;
            this.referenceResolver = serializer.ReferenceResolver;
            this.serializer = serializer;
            this.vw = vwPool.Native;
            this.defaultMarshaller = defaultMarshaller;
            this.jsonSerializer = jsonSerializer;

            this.DefaultNamespaceContext = new VowpalWabbitMarshalContext(this.vw);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            //if (this.vwAllReduce != null)
            //{
            //    this.vwAllReduce.Dispose();
            //    this.vwAllReduce = null;
            //}

            if (this.vw != null)
            {
                this.vw.Dispose();
                this.vw = null;
            }

            if (this.referenceResolver != null)
            {
                this.referenceResolver.Dispose();
                this.referenceResolver = null;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VowpalWabbitJson"/> class.
        /// </summary>
        /// <param name="vwPool">The VW native instance.</param>
        /// <param name="referenceResolver">An optional reference resolver.</param>
        public VowpalWabbitJsonSerializer(IVowpalWabbitExamplePool vwPool, VowpalWabbitJsonReferenceResolver referenceResolver = null)
        {
            Contract.Requires(vwPool != null);

            this.extensions = new List<VowpalWabbitJsonExtension> { this.HandleMultiProperty };
            this.jsonSerializer = new JsonSerializer();

            this.vwPool = vwPool;
            this.referenceResolver = referenceResolver;

            this.ExampleBuilder = new VowpalWabbitJsonBuilder(this, this.vwPool, VowpalWabbitDefaultMarshaller.Instance, this.jsonSerializer);
        }