Ejemplo n.º 1
0
 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++;
         }
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
        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());
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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());
        }