Exemplo 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);
        }
Exemplo 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)
        {
            Contract.Requires(vwPool != null);

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

            this.ExampleBuilder = new VowpalWabbitJsonBuilder(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)
        {
            Contract.Requires(vwPool != null);

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

            this.ExampleBuilder = new VowpalWabbitJsonBuilder(this.vwPool, this.defaultMarshaller, this.jsonSerializer);
        }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.pool != null)
         {
             this.pool.Dispose();
             this.pool = null;
         }
     }
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 7
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.pool != null)
         {
             this.pool.Dispose();
             this.pool = null;
         }
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of <see cref="VowpalWabbitJsonBuilder"/>.
        /// </summary>
        public VowpalWabbitJsonBuilder(IVowpalWabbitExamplePool vwPool, VowpalWabbitDefaultMarshaller defaultMarshaller, JsonSerializer jsonSerializer)
        {
            Contract.Requires(vw != null);
            Contract.Requires(defaultMarshaller != null);
            Contract.Requires(jsonSerializer != null);

            this.vw = vwPool.Native;
            this.defaultMarshaller = new VowpalWabbitDefaultMarshaller();
            this.jsonSerializer    = new JsonSerializer();

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

            this.vw = vwPool.Native;
            this.defaultMarshaller = new VowpalWabbitDefaultMarshaller();
            this.jsonSerializer = new JsonSerializer();

            this.Context = new VowpalWabbitMarshalContext(vwPool);
            this.DefaultNamespaceContext = new VowpalWabbitMarshalContext(this.vw, this.Context.ExampleBuilder);
        }
        /// <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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 13
0
 public VowpalWabbitThreadSafeExamplePool(IVowpalWabbitExamplePool pool)
 {
     this.pool     = pool;
     this.poolLock = new object();
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of <see cref="VowpalWabbitJsonBuilder"/>.
 /// </summary>
 public VowpalWabbitJsonBuilder(IVowpalWabbitExamplePool vwPool, VowpalWabbitDefaultMarshaller defaultMarshaller, JsonSerializer jsonSerializer, int multiIndex = -1)
     : this(null, vwPool, defaultMarshaller, jsonSerializer, multiIndex)
 {
 }
 public VowpalWabbitThreadSafeExamplePool(IVowpalWabbitExamplePool pool)
 {
     this.pool = pool;
     this.poolLock = new object();
 }
        /// <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);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="VowpalWabbitMarshalContext"/> class.
 /// </summary>
 /// <param name="vwPool">The VW instance the example will be imported to.</param>
 /// <param name="dictionary">Dictionary used for dictify operation.</param>
 /// <param name="fastDictionary">Dictionary used for dictify operation.</param>
 public VowpalWabbitMarshalContext(IVowpalWabbitExamplePool vwPool, Dictionary<string, string> dictionary = null, Dictionary<object, string> fastDictionary = null)
     : this(vwPool.Native, new VowpalWabbitExampleBuilder(vwPool), dictionary, fastDictionary)
 {
     disposeExampleBuilder = true;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VowpalWabbitMarshalContext"/> class.
 /// </summary>
 /// <param name="vw">The VW instance the example will be imported to.</param>
 /// <param name="dictionary">Dictionary used for dictify operation.</param>
 /// <param name="fastDictionary">Dictionary used for dictify operation.</param>
 public VowpalWabbitMarshalContext(IVowpalWabbitExamplePool vwPool, Dictionary <string, string> dictionary = null, Dictionary <object, string> fastDictionary = null)
     : this(vwPool.Native, new VowpalWabbitExampleBuilder(vwPool), dictionary, fastDictionary)
 {
     disposeExampleBuilder = true;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="VowpalWabbitJsonBuilder"/>.
 /// </summary>
 public VowpalWabbitJsonBuilder(IVowpalWabbitExamplePool vwPool, VowpalWabbitDefaultMarshaller defaultMarshaller, JsonSerializer jsonSerializer, int multiIndex = -1)
     : this(null, vwPool, defaultMarshaller, jsonSerializer, multiIndex)
 {
 }