Exemple #1
0
        public static FixtureKind Unserial(XmlElement el, Hull hull)
        {
            if (el.Name != "FixtureKind")
                throw new ArgumentException();

            var materialName = el.Attributes["Material"].Value;

            return new FixtureKind(
               el.Attributes["Name"].Value,
               hull.Materials.First(m => m.Name == materialName),
               double.Parse(el.Attributes["Size"].Value)
            );
        }
Exemple #2
0
        public static Hull Unserial(XmlElement root)
        {
            var culture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            try
            {

                if (root.Name != "Hull")
                    throw new ArgumentException();

                var hull = new Hull(root.Attributes["Name"].Value);

                foreach (XmlElement el in root.GetElementsByTagName("HullMaterial"))
                    hull.AddMaterial(HullMaterial.Unserial(el));

                foreach (XmlElement el in root.GetElementsByTagName("FixtureKind"))
                    hull.AddFixtureKind(FixtureKind.Unserial(el, hull));

                foreach (XmlElement el in root.GetElementsByTagName("Fixture"))
                {
                    var f = Fixture.Unserial(el, hull);
                    //hull.AddFixture(f.MakeGeometry(), f);
                }

                //foreach (XmlElement el in root.GetElementsByTagName("RoomTemplate"))
                //    hull.AddRoomTemplate(RoomTemplate.Unserial(el, hull));

                //foreach (XmlElement el in root.GetElementsByTagName("Room"))
                //{
                //    var r = Room.Unserial(el, hull);
                //    hull.AddRoom(r.MakeGeometry(), r);
                //}

                //foreach (XmlElement el in root.GetElementsByTagName("CoverFragment"))
                //{
                //    var c = CoverFragment.Unserial(el, hull);
                //    hull.AddCover(c.MakeGeometry(), c);
                //}
                return hull;
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = culture;
            }
        }
Exemple #3
0
        public static Fixture Unserial(XmlElement el, Hull hull)
        {
            if (el.Name != "Fixture")
                throw new ArgumentException();

            var fixtureKindName = el.Attributes["Kind"].Value;

            return new Fixture(
               hull.FixtureKinds.First(m => m.Name == fixtureKindName),
               (Point3D)_pointsConverter.ConvertFromString(el.Attributes["From"].Value),
               (Point3D)_pointsConverter.ConvertFromString(el.Attributes["To"].Value)
            );
        }