public PsonEncoder(Stream output, IList <string> initialDictionary = null, PsonOptions options = PsonOptions.None) : base(output) { this.options = options; if (initialDictionary == null) { dictionary = null; } else { dictionary = new Dictionary <string, uint>(initialDictionary.Count); uint index = 0; foreach (var key in initialDictionary) { dictionary[key] = index++; } } }
public PsonDecoder(Stream input, IList <string> initialDictionary = null, PsonOptions options = PsonOptions.None, int allocationLimit = -1) { if (ReferenceEquals(input, null)) { throw new ArgumentNullException("input"); } this.input = input; this.options = options; this.allocationLimit = allocationLimit; if (initialDictionary == null) { dictionary = null; } else { dictionary = new List <string>(initialDictionary); } }
public static byte[] Encode(object structure, IList <string> initialDictionary = null, PsonOptions options = PsonOptions.None) { var output = new MemoryStream(); using (var encoder = new PsonEncoder(output, initialDictionary, options)) { encoder.Write(structure); return(output.ToArray()); } }
public static object Decode(byte[] buffer, out JsonNode root, out String stringify, IList <string> initialDictionary = null, PsonOptions options = PsonOptions.None, int allocationLimit = -1) { var input = new MemoryStream(buffer); using (var decoder = new PsonDecoder(input, initialDictionary, options, allocationLimit)) { Object retVal = decoder.Read(out root); stringify = decoder.jsonTxt.ToString(); return(retVal); } }
public static object Decode(byte[] buffer, IList <string> initialDictionary = null, PsonOptions options = PsonOptions.None, int allocationLimit = -1) { var input = new MemoryStream(buffer); using (var decoder = new PsonDecoder(input, initialDictionary, options, allocationLimit)) return(decoder.Read()); }