public void Ifc4TableStorageTest()
        {
            const string file    = "..\\..\\SampleHouseFromIfc.xlsx";
            var          model   = IfcStore.Open("SampleHouse4.ifc");
            var          mapping = ModelMapping.Load(Properties.Resources.IFC4SampleMapping);

            mapping.Init(model.Metadata);

            var w = new Stopwatch();

            w.Start();
            var storage = new TableStore(model, mapping);

            storage.Store(file);
            w.Stop();
            //Debug.WriteLine(@"{0}ms to store the data as a table.", w.ElapsedMilliseconds);
            Trace.WriteLine(string.Format(@"{0}ms to store the data as a table.", w.ElapsedMilliseconds));

            var loaded = new IO.Memory.MemoryModel(new Ifc4.EntityFactory());

            using (var txn = loaded.BeginTransaction("Import from XLSX"))
            {
                storage = new TableStore(loaded, mapping);
                storage.LoadFrom(file);
                txn.Commit();
            }
        }
        public void Ifc4PSetsTest()
        {
            const string file  = "PSetsSample.xlsx";
            var          model = new IO.Memory.MemoryModel(new Ifc4.EntityFactory());

            using (var txn = model.BeginTransaction("Sample data"))
            {
                model.EntityNew += entity =>
                {
                    var root = entity as IfcRoot;
                    if (root != null)
                    {
                        root.GlobalId = Guid.NewGuid();
                    }
                };
                var slab = model.Instances.New <IfcSlab>(s => s.Name = "Tremendous slab");
                model.Instances.New <IfcRelDefinesByProperties>(r =>
                {
                    r.RelatedObjects.Add(slab);
                    r.RelatingPropertyDefinition = model.Instances.New <IfcPropertySet>(ps =>
                    {
                        ps.Name = "Slab properties A";
                        ps.HasProperties.Add(model.Instances.New <IfcPropertySingleValue>(p =>
                        {
                            p.Name         = "Property AA";
                            p.NominalValue = new IfcLengthMeasure(5.5);
                        }));
                        ps.HasProperties.Add(model.Instances.New <IfcPropertySingleValue>(p =>
                        {
                            p.Name         = "Property AB";
                            p.NominalValue = new IfcLogical(true);
                        }));
                    });
                });
                model.Instances.New <IfcRelDefinesByProperties>(r =>
                {
                    r.RelatedObjects.Add(slab);
                    r.RelatingPropertyDefinition = model.Instances.New <IfcPropertySet>(ps =>
                    {
                        ps.Name = "Slab properties B";
                        ps.HasProperties.Add(model.Instances.New <IfcPropertySingleValue>(p =>
                        {
                            p.Name         = "Property BA";
                            p.NominalValue = new IfcInteger(5);
                        }));
                        ps.HasProperties.Add(model.Instances.New <IfcPropertySingleValue>(p =>
                        {
                            p.Name         = "Property BB";
                            p.NominalValue = new IfcLabel("LabellebaL");
                        }));
                    });
                });
                txn.Commit();
            }


            var mapping = ModelMapping.Load(Properties.Resources.IFC4SampleMapping);

            mapping.Init(model.Metadata);

            var w = new Stopwatch();

            w.Start();
            var storage = new TableStore(model, mapping);

            storage.Store(file);
            w.Stop();
            //Debug.WriteLine(@"{0}ms to store the data as a table.", w.ElapsedMilliseconds);
            Trace.WriteLine(string.Format(@"{0}ms to store the data as a table.", w.ElapsedMilliseconds));

            var loaded = new IO.Memory.MemoryModel(new Ifc4.EntityFactory());

            using (var txn = loaded.BeginTransaction("Import from XLSX"))
            {
                storage = new TableStore(loaded, mapping);
                storage.LoadFrom(file);
                txn.Commit();
            }

            var sl = loaded.Instances.FirstOrDefault <IfcSlab>();

            Assert.IsNotNull(sl);

            var rels = sl.IsDefinedBy.ToList();

            Assert.AreEqual(2, rels.Count);

            foreach (var rel in rels)
            {
                var pSet = rel.RelatingPropertyDefinition as IfcPropertySet;
                Assert.IsNotNull(pSet);
                Assert.IsNotNull(pSet.Name);

                if (pSet.Name == "Slab properties A")
                {
                    var propA = pSet.HasProperties.OfType <IfcPropertySingleValue>().First(p => p.Name == "Property AA");
                    Assert.IsNotNull(propA);
                    Assert.IsNotNull(propA.NominalValue);
                    Assert.IsTrue(Math.Abs((IfcLengthMeasure)propA.NominalValue - 5.5) < 1e-9);
                    var propB = pSet.HasProperties.OfType <IfcPropertySingleValue>().First(p => p.Name == "Property AB");
                    Assert.IsNotNull(propB);
                    Assert.IsNotNull(propB.NominalValue);
                    Assert.IsTrue(((IfcLogical)propB.NominalValue).Equals((IfcLogical)true));
                }
                if (pSet.Name == "Slab properties B")
                {
                    var propA = pSet.HasProperties.OfType <IfcPropertySingleValue>().First(p => p.Name == "Property BA");
                    Assert.IsNotNull(propA);
                    Assert.IsNotNull(propA.NominalValue);
                    Assert.IsTrue(((IfcInteger)propA.NominalValue).Equals((IfcInteger)5));
                    var propB = pSet.HasProperties.OfType <IfcPropertySingleValue>().First(p => p.Name == "Property BB");
                    Assert.IsNotNull(propB);
                    Assert.IsNotNull(propB.NominalValue);
                    Assert.IsTrue(((IfcLabel)propB.NominalValue).Equals((IfcLabel)"LabellebaL"));
                }
            }
        }