Esempio n. 1
0
        public void Serialize(Dictionary <string, object> json, BinaryWriter bw)
        {
            elements = new List <string>();

            if (PointSetElements != null)
            {
                foreach (var PointSet in PointSetElements)
                {
                    PointSet.Serialize(json, bw);
                    elements.Add(PointSet.uid.ToString());
                }
            }


            if (LineSetElements != null)
            {
                foreach (var LineSet in LineSetElements)
                {
                    LineSet.Serialize(json, bw);
                    elements.Add(LineSet.uid.ToString());
                }
            }

            if (SurfaceElements != null)
            {
                foreach (var Surface in SurfaceElements)
                {
                    Surface.Serialize(json, bw);
                    elements.Add(Surface.uid.ToString());
                }
            }

            if (VolumeElements != null)
            {
                foreach (var VolumeElement in VolumeElements)
                {
                    VolumeElement.Serialize(json, bw);
                    elements.Add(VolumeElement.uid.ToString());
                }
            }
        }
Esempio n. 2
0
        public void Deserialize(Dictionary <string, object> json, BinaryReader br)
        {
            SurfaceElements  = new List <SurfaceElement>();
            PointSetElements = new List <PointSetElement>();
            VolumeElements   = new List <VolumeElement>();
            LineSetElements  = new List <LineSetElement>();

            foreach (string id in json.Keys)
            {
                string data = json[id].ToString();
                Dictionary <string, object> thisDict = JsonConvert.DeserializeObject <Dictionary <string, object> >(data);

                if (thisDict.ContainsKey("__class__"))
                {
                    switch (thisDict["__class__"].ToString().ToUpper())
                    {
                    case "SURFACEELEMENT":
                    {
                        SurfaceElement obj = (SurfaceElement)ObjectFactory.GetObjectFromData(json, br, data);
                        if (obj != null)
                        {
                            SurfaceElements.Add(obj);
                        }
                    }
                    break;

                    case "POINTSETELEMENT":
                    {
                        PointSetElement obj = (PointSetElement)ObjectFactory.GetObjectFromData(json, br, data);
                        if (obj != null)
                        {
                            PointSetElements.Add(obj);
                        }
                    }
                    break;

                    case "VOLUMEELEMENT":
                    {
                        VolumeElement obj = (VolumeElement)ObjectFactory.GetObjectFromData(json, br, data);
                        if (obj != null)
                        {
                            VolumeElements.Add(obj);
                        }
                    }
                    break;

                    case "LINESETELEMENT":
                    {
                        LineSetElement obj = (LineSetElement)ObjectFactory.GetObjectFromData(json, br, data);
                        if (obj != null)
                        {
                            LineSetElements.Add(obj);
                        }
                    }
                    break;

                    default:

                        break;
                    }
                }
            }
        }