Exemple #1
0
        protected override bool Create <T>(IEnumerable <T> objects, bool replaceAll = false)
        {
            string fileName = _fileSettings.FullFileName();

            GBXML gbx = new GBXML();

            if (!_xmlSettings.NewFile)
            {
                gbx = XMLReader.Load(_fileSettings.FullFileName()); //Load up the previous file to append to
            }
            if (_xmlSettings.UnitType == UnitType.Imperial)
            {
                gbx.TemperatureUnit      = "F";
                gbx.LengthUnit           = "Feet";
                gbx.AreaUnit             = "SquareFeet";
                gbx.VolumeUnit           = "CubicFeet";
                gbx.UseSIUnitsForResults = "false";
            }

            if (typeof(IBHoMObject).IsAssignableFrom(typeof(T)))
            {
                XML.GBXMLSerializer.Serialize(objects, gbx, fileName, _xmlSettings);
                XMLWriter.Save(fileName, gbx);
            }

            return(true);
        }
Exemple #2
0
        private IEnumerable <IBHoMObject> Read(Type type = null)
        {
            BH.oM.XML.GBXML gbx = XMLReader.Load(_fileSettings.FullFileName());

            if (type == null)
            {
                return(ReadFullXMLFile(gbx));
            }
            else if (type == typeof(BHE.Building))
            {
                return(ReadBuilding(gbx));
            }
            else if (type == typeof(BHE.Panel))
            {
                return(ReadPanels(gbx));
            }

            /*else if (type == typeof(BHC.Construction))
             *  return ReadConstructions(gbx);
             * else if (type == typeof(BH.oM.Physical.Properties.Material))
             *  return ReadMaterials(gbx);*/
            else if (type == typeof(BHA.Level))
            {
                return(ReadLevels(gbx));
            }
            else
            {
                return(ReadFullXMLFile(gbx));
            }
        }