Exemple #1
0
        public static MpRoot PackMultiple(IEnumerable values)
        {
            MpRoot root = new MpRoot();

            foreach (object item in values)
            {
                root.Add(Pack(item));
            }
            return(root);
        }
Exemple #2
0
        public static MpRoot PackMultiple(params object[] values)
        {
            MpRoot root = new MpRoot(values.Length);

            for (int t = 0; t < values.Length; t++)
            {
                root.Add(Pack(values[t]));
            }
            return(root);
        }
Exemple #3
0
        public static MpRoot PackMultiple(MsgPackSettings settings, IEnumerable values)
        {
            MpRoot root = new MpRoot(settings);

            foreach (object item in values)
            {
                root.Add(Pack(item, settings));
            }
            return(root);
        }
Exemple #4
0
        public static MpRoot PackMultiple(MsgPackSettings settings, params object[] values)
        {
            MpRoot root = new MpRoot(settings, values.Length);

            for (int t = 0; t < values.Length; t++)
            {
                root.Add(Pack(values[t], settings));
            }
            return(root);
        }
Exemple #5
0
        public static MpRoot UnpackMultiple(Stream stream, MsgPackSettings settings)
        {
            MpRoot items = new MpRoot(settings)
            {
                storedOffset = stream.Position
            };
            long len     = stream.Length - 1;
            long lastpos = stream.Position;

            while (stream.Position < len)
            {
                try {
                    items.Add(Unpack(stream, settings));
                    lastpos = stream.Position;
                } catch (Exception ex) {
                    items.Add(new MpError(settings, ex, "Offset after parsing error is ", stream.Position)
                    {
                        storedOffset = lastpos, storedLength = stream.Position - lastpos
                    });
                    if (settings.ContinueProcessingOnBreakingError)
                    {
                        if (lastpos == stream.Position && stream.Position < len)
                        {
                            FindNextValidTypeId(stream);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            items.storedLength = stream.Position - items.storedOffset;
            return(items);
        }
Exemple #6
0
        public static MpRoot UnpackMultiple(Stream stream)
        {
            MpRoot items   = new MpRoot();
            long   len     = stream.Length - 1;
            long   lastpos = stream.Position;

            while (stream.Position < len)
            {
                try {
                    items.Add(Unpack(stream));
                    lastpos = stream.Position;
                } catch (Exception ex) {
                    throw new MsgPackException(string.Concat("error while reading item [", items.Count, "] at offset ", lastpos, " (read up to ", stream.Position, "). See inner exception for more details."), ex, lastpos);
                }
            }

            return(items);
        }