public SerializationContext()
        {
            _outputTypeComment = true;
            _outputTypeInformation = true;
            _referenceWritingType = ReferenceOption.ErrorCircularReferences;

            _typeAliases = new TypeAliasCollection();

            // collections
            _collectionHandlers = new List<CollectionHandler>();
            _collectionHandlers.Add(new GenericCollectionHandler());
            _collectionHandlers.Add(new ArrayHandler());
            _collectionHandlers.Add(new ListHandler());
            _collectionHandlers.Add(new StackHandler());
            _collectionHandlers.Add(new GenericStackHandler());
            _collectionHandlers.Add(new CollectionConstructorHandler());

            // type handlers
            _typeHandlerFactory = new TypeDataRepository(this);
            _parameters = new Hashtable();

            // type conversion
            _typeHandlerFactory.RegisterTypeConverter(typeof(System.Collections.BitArray), new BitArrayConverter());

            this.expressionHandlers = new ExpressionHandlerCollection(this);
            this.defaultValues = new DefaultValueCollection();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a json writer that writes to the <paramref name="writer"/> and uses
        /// the InvariantCulture for any formatting.
        /// </summary>
        /// <param name="writer">the text writer that will be written to</param>
        /// <param name="indent">setting that specifies whether to indent</param>
        /// <param name="culture">The culture to use for formatting</param>
        public JsonWriter(TextWriter writer, bool indent, CultureInfo culture, TypeAliasCollection typeAliases)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");
            this._writer = writer;
            this.typeAliases = typeAliases ?? new TypeAliasCollection();
            this.culture = culture ?? CultureInfo.InvariantCulture;

            _currentState = new InitialState(this);
            if (!indent)
                indentSize = 0;
        }
 public TypeJsonWriter(TextWriter writer, bool indent, TypeAliasCollection typeAliases)
     : base(writer, indent, typeAliases)
 {
 }
Exemplo n.º 4
0
 public Parser(ITokenStream tokenStream, TypeAliasCollection typeAliases)
 {
     _tokenStream = tokenStream;
     this.typeAliases = typeAliases ?? new TypeAliasCollection();
 }
Exemplo n.º 5
0
 public Parser(TextReader reader, TypeAliasCollection typeAliases)
     : this(new TokenStream(reader), typeAliases)
 {
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a json writer that writes to the <paramref name="writer"/> and uses
 /// the InvariantCulture for any formatting.
 /// </summary>
 /// <param name="writer">the text writer that will be written to</param>
 /// <param name="indent">setting that specifies whether to indent</param>
 /// <param name="typeAliases">type aliases</param>
 public JsonWriter(TextWriter writer, bool indent, TypeAliasCollection typeAliases) 
     : this(writer, indent, CultureInfo.InvariantCulture, typeAliases)
 {
 }