string AddState(ref uos uos) { State nstate = new State(); nstate.id = GenerateId(); nstate.Name = "Blunt"; uos.State = AddElement(uos.State, nstate); return(nstate.id); }
public static void AssertIsMinimumExample(iso_10303 iso10303) { Assert.IsNotNull(iso10303); Assert.IsNotNull(iso10303.iso_10303_28_header); Assert.AreEqual("An Example", iso10303.iso_10303_28_header.name); Assert.AreEqual(new DateTime(2010, 11, 12, 13, 04, 00), iso10303.iso_10303_28_header.time_stamp); Assert.AreEqual("John Hancock", iso10303.iso_10303_28_header.author); Assert.AreEqual("MegaCorp", iso10303.iso_10303_28_header.organization); Assert.AreEqual("IfcDotNet Library", iso10303.iso_10303_28_header.originating_system); Assert.AreEqual("a preprocessor", iso10303.iso_10303_28_header.preprocessor_version); Assert.AreEqual("documentation", iso10303.iso_10303_28_header.documentation); Assert.AreEqual("none", iso10303.iso_10303_28_header.authorization); Assert.IsNotNull(iso10303.uos, "iso10303.uos is null"); uos uos = iso10303.uos; Assert.AreEqual("uos_1", uos.id); Assert.IsNotNull(uos.configuration, "iso10303.uos.configuration is null"); Assert.AreEqual(1, uos.configuration.Length, "uos.configuration does not have 1 item in it"); Assert.AreEqual("i-ifc2x3", uos.configuration[0]); Assert.IsNotNull(uos as uos1, "uos cannot be converted to uos1"); uos1 uos1 = uos as uos1; Assert.IsNotNull(uos1, "uos1 is null"); Assert.IsNotNull(uos1.Items, "uos1.items is null"); Assert.AreEqual(3, uos1.Items.Length, "uos1.Items does not have 3 items in it"); IfcOrganization org = uos1.Items[0] as IfcOrganization; Assert.IsNotNull(org, "org is null"); Assert.AreEqual("i1101", org.entityid, "entityid is not i1101"); Assert.AreEqual("MegaCorp", org.Name); IfcCartesianPoint pnt = uos1.Items[1] as IfcCartesianPoint; Assert.IsNotNull(pnt, "pnt is null"); Assert.AreEqual("i101", pnt.entityid); Assert.IsNotNull(pnt.Coordinates); Assert.IsNotNull(pnt.Coordinates.Items); Assert.AreEqual(3, pnt.Coordinates.Items.Length); Assert.AreEqual(2500, pnt.Coordinates[0].Value); //TODO shorten the number of properties needed to be called to get the value. pnt.Coordinates[0] would be perfect! Assert.AreEqual(0, pnt.Coordinates[1].Value); Assert.AreEqual(0, pnt.Coordinates[2].Value); IfcDirection dir = uos1.Items[2] as IfcDirection; Assert.IsNotNull(dir, "dir is null"); Assert.AreEqual("i102", dir.entityid); Assert.IsNotNull(dir.DirectionRatios); Assert.IsNotNull(dir.DirectionRatios.Items); Assert.AreEqual(3, dir.DirectionRatios.Items.Length); Assert.AreEqual(0, dir.DirectionRatios[0].Value); Assert.AreEqual(1, dir.DirectionRatios[1].Value); Assert.AreEqual(0, dir.DirectionRatios[0].Value); }
private void button2_Click(object sender, EventArgs e) { uos uos1 = new uos(); string _xmlfilename = GetExeDirectory() + "ISO13399.xml"; System.Xml.Serialization.XmlSerializer xSerializer = new System.Xml.Serialization.XmlSerializer(uos1.GetType()); System.IO.StreamReader str1 = new System.IO.StreamReader(_xmlfilename); uos1 = (uos)xSerializer.Deserialize(str1); str1.Close(); }
private void button1_Click(object sender, EventArgs e) { List <object> items = new List <object>(); uos uos1 = new uos(); AddOrganization(ref uos1); AddState(ref uos1); AddItem_characteristic_association(ref uos1); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(uos1.GetType()); x.Serialize(Console.Out, uos1); }
string AddOrganization(ref uos uos) { Organization org = new Organization(); org.Delivery_address = "Someotherstreet 2, Sometown, Sweden"; org.Id = "SE556677889901"; org.id = GenerateId(); org.Organization_name = "CTC -Cutting Tool Company"; org.Postal_address = "Box 0000, Sometown, Sweden"; org.Visitor_address = "Somestreet 1,Sometown, Sweden"; uos.Organization = AddElement(uos.Organization, org); return(org.id); }
string AddItem_characteristic_association(ref uos uos) { Item_characteristic_association item = new Item_characteristic_association(); item.id = GenerateId(); item.Associated_characteristic = new Item_characteristic_associationAssociated_characteristic(); item.Associated_characteristic.Item = new Grade(); Grade grade = (Grade)item.Associated_characteristic.Item; grade.@ref = AddGrade(ref uos); item.Associated_item = new Item_definition[1]; item.Relation_type = "used_for"; uos.Item_characteristic_association = AddElement(uos.Item_characteristic_association, item); return(item.id); }
string AddGrade(ref uos uos) { Grade g = new Grade(); g.id = GenerateId(); Coating c = new Coating(); c.id = GenerateId(); c.Coating_name = "TiAlN"; c.Coating_process = "Coating_process"; uos.Coating = AddElement(uos.Coating, c); Substrate s = new Substrate(); s.id = GenerateId(); s.Name = "WC"; uos.Substrate = AddElement(uos.Substrate, s); Material_designation m = new Material_designation(); m.id = GenerateId(); m.Material_name = "P"; uos.Material_designation = AddElement(uos.Material_designation, m); g.Coating = new Coating[1]; g.Coating[0] = new Coating(); g.Coating[0].@ref = c.id; g.Substrate = new Substrate[1]; g.Substrate[0] = new Substrate(); g.Substrate[0].@ref = s.id; g.Workpiece_material = new Material_designation[1]; g.Workpiece_material[0] = new Material_designation(); g.Workpiece_material[0].@ref = m.id; uos.Grade = AddElement(uos.Grade, g); return(g.id); }