Create() public static method

Creates a new instance of the deserialization helper.
public static Create ( Byte content ) : Deserializer
content Byte The content to deserialize.
return Deserializer
Exemplo n.º 1
0
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var bp = new BarPlotValue();

            using (var ds = Deserializer.Create(content))
            {
                bp.Deserialize(ds);
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new BarPoints();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (var j = 0; j < count; j++)
                    {
                        points.Add(ds.GetDouble());
                    }

                    points.BarWidth = ds.GetDouble();
                    bp.AddSeries(points);
                }
            }

            return(bp);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var pp = new PolarPlotValue();

            using (var ds = Deserializer.Create(content))
            {
                pp.Deserialize(ds);
                pp.FractionSymbol = ds.GetString();
                pp.FractionUnit   = ds.GetDouble();
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new Points <PointPair>();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (int j = 0; j < count; j++)
                    {
                        var x = ds.GetDouble();
                        var y = ds.GetDouble();

                        points.Add(new PointPair
                        {
                            Angle     = x,
                            Magnitude = y
                        });
                    }

                    pp.AddSeries(points);
                }
            }

            return(pp);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var p2 = new Plot2DValue();

            using (var ds = Deserializer.Create(content))
            {
                p2.Deserialize(ds);
                p2.IsLogX = ds.GetBoolean();
                p2.IsLogY = ds.GetBoolean();
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new Points <PointPair>();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (int j = 0; j < count; j++)
                    {
                        var x = ds.GetDouble();
                        var y = ds.GetDouble();

                        points.Add(new PointPair
                        {
                            X = x,
                            Y = y
                        });
                    }

                    p2.AddSeries(points);
                }
            }

            return(p2);
        }
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var sp = new SurfacePlotValue();

            using (var ds = Deserializer.Create(content))
            {
                sp.Deserialize(ds);
                sp.IsMesh       = ds.GetBoolean();
                sp.ColorPalette = (ColorPalettes)ds.GetInt();
                sp.data.Deserialize(ds);
                var count = ds.GetInt();

                for (int j = 0; j < count; j++)
                {
                    var x = ds.GetDouble();
                    var y = ds.GetDouble();
                    var z = ds.GetDouble();

                    data.Add(new Vertex
                    {
                        X = x,
                        Y = y,
                        Z = z
                    });
                }
            }

            return(sp);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new instance from a given binary content.
        /// </summary>
        /// <param name="content">The binary content.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var sp = new SubPlotValue();

            using (var ds = Deserializer.Create(content))
            {
                sp.Title   = ds.GetString();
                sp.Rows    = ds.GetInt();
                sp.Columns = ds.GetInt();
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var subplot = new SubPlot();
                    subplot.Row        = ds.GetInt();
                    subplot.RowSpan    = ds.GetInt();
                    subplot.Column     = ds.GetInt();
                    subplot.ColumnSpan = ds.GetInt();
                    var name = ds.GetString();
                    subplot.Plot = (PlotValue)Value.Deserialize(name, ds.GetBytes());
                    sp.subplots.Add(subplot);
                }
            }

            return(sp);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new string value from the binary content.
        /// </summary>
        /// <param name="content">The data which contains the content.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var value = string.Empty;

            using (var ds = Deserializer.Create(content))
            {
                value = ds.GetString();
            }

            return(new StringValue(value));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new instance from the given bytes.
        /// </summary>
        /// <param name="content">The binary content to create a new instance from.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var cp = new ComplexPlotValue();

            using (var ds = Deserializer.Create(content))
            {
                cp.Deserialize(ds);
                var ctn = ds.GetBytes();
                cp.f = new FunctionValue().Deserialize(ctn) as FunctionValue;
            }

            return(cp);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates a new object value from the binary content.
        /// </summary>
        /// <param name="content">The data which contains the content.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(Byte[] content)
        {
            var dict = new Dictionary <String, Value>();

            using (var ds = Deserializer.Create(content))
            {
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var key   = ds.GetString();
                    var value = ds.GetValue();
                    dict[key] = value;
                }
            }

            return(new ObjectValue(dict));
        }
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var cp = new ContourPlotValue();

            using (var ds = Deserializer.Create(content))
            {
                cp.Deserialize(ds);
                cp.ColorPalette = (ColorPalettes)ds.GetInt();
                cp.ShowLevel    = ds.GetBoolean();
                cp.Levels       = new double[ds.GetInt()];

                for (var i = 0; i < Levels.Length; i++)
                {
                    Levels[i] = ds.GetDouble();
                }

                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new Points <ContourPoint>();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (int j = 0; j < count; j++)
                    {
                        var x = ds.GetDouble();
                        var y = ds.GetDouble();
                        var z = ds.GetDouble();

                        points.Add(new ContourPoint
                        {
                            X         = x,
                            Y         = y,
                            Magnitude = z
                        });
                    }

                    cp.AddSeries(points);
                }
            }

            return(cp);
        }
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var hm = new HeatmapPlotValue();

            using (var ds = Deserializer.Create(content))
            {
                hm.Deserialize(ds);
                hm.ColorPalette = (ColorPalettes)ds.GetInt();
                hm.Minimum      = ds.GetDouble();
                hm.Maximum      = ds.GetDouble();

                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new Points <HeatPoint>();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (int j = 0; j < count; j++)
                    {
                        var x = ds.GetInt();
                        var y = ds.GetInt();
                        var z = ds.GetDouble();

                        points.Add(new HeatPoint
                        {
                            Column    = x,
                            Row       = y,
                            Magnitude = z
                        });
                    }

                    hm.AddSeries(points);
                }
            }

            return(hm);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var ep = new ErrorPlotValue();

            using (var ds = Deserializer.Create(content))
            {
                ep.Deserialize(ds);
                ep.IsLogX = ds.GetBoolean();
                ep.IsLogY = ds.GetBoolean();
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new Points <ErrorPointPair>();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (int j = 0; j < count; j++)
                    {
                        var x    = ds.GetDouble();
                        var y    = ds.GetDouble();
                        var xerr = ds.GetDouble();
                        var yerr = ds.GetDouble();

                        points.Add(new ErrorPointPair
                        {
                            X    = x,
                            Y    = y,
                            Xerr = xerr,
                            Yerr = yerr
                        });
                    }

                    ep.AddSeries(points);
                }
            }

            return(ep);
        }
        /// <summary>
        /// Tries to create a new instance from the given bytes.
        /// </summary>
        /// <param name="content">The binary content.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            if (content.Length == 0)
            {
                return(this);
            }

            using (var ds = Deserializer.Create(content))
            {
                var args = ds.GetInt();
                _arguments = new string[args];

                for (int i = 0; i != args; i++)
                {
                    _arguments[i] = ds.GetString();
                }

                _body = ds.GetString();
            }

            return(new FunctionValue(_arguments, _body));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Converts a set of bytes to a new instance.
        /// </summary>
        /// <param name="content">The binary representation.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var p3 = new Plot3DValue();

            using (var ds = Deserializer.Create(content))
            {
                p3.Deserialize(ds);
                p3.IsLogX = ds.GetBoolean();
                p3.IsLogY = ds.GetBoolean();
                p3.IsLogZ = ds.GetBoolean();
                var length = ds.GetInt();

                for (var i = 0; i < length; i++)
                {
                    var points = new Points <PointTriple>();
                    points.Deserialize(ds);
                    var count = ds.GetInt();

                    for (int j = 0; j < count; j++)
                    {
                        var x = ds.GetDouble();
                        var y = ds.GetDouble();
                        var z = ds.GetDouble();

                        points.Add(new PointTriple
                        {
                            X = x,
                            Y = y,
                            Z = z
                        });
                    }

                    p3.AddSeries(points);
                }
            }

            return(p3);
        }