Ejemplo n.º 1
0
        public static List <Floor> LoadFloorPlans()
        {
            List <Floor> floors = new List <Floor>();

            try
            {
                log.Info("Trying to load floorplans...");
                if (!Directory.Exists(floorplanpath))
                {
                    log.Warn("No floor folder exists no floorplan to load.");
                }
                else
                {
                    IEnumerable <string> floorplanlist = Directory.EnumerateFiles(floorplanpath, "*.flp");
                    foreach (string file in floorplanlist)
                    {
                        log.Info($"Loading floorplan {file}...");
                        string json     = File.ReadAllText(file);
                        Floor  newfloor = JsonConvert.DeserializeObject <Floor>(json);
                        newfloor.AcceptChanges();
                        floors.Add(newfloor);
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                return(new List <Floor>());
            }
            return(floors);
        }