public GlazingConstruction Add(GlazingConstruction obj)
        {
            if (obj == null)
            {
                return(null);
            }
            if (GlazingConstructions == null)
            {
                GlazingConstructions = new List <GlazingConstruction>();
            }


            foreach (var m in obj.Layers)
            {
                if (m.Material is GlazingMaterial)
                {
                    this.Add((GlazingMaterial)m.Material);
                }
            }


            if (!GlazingConstructions.Any(i => i.Name == obj.Name))
            {
                GlazingConstructions.Add(obj);
                return(obj);
            }
            else
            {
                var oc = GlazingConstructions.Single(o => o.Name == obj.Name);

                CopyObjectData(obj, oc, "", BindingFlags.Public | BindingFlags.Instance);

                return(oc);
            }
        }
        public T getElementByName <T>(string name)
        {
            // materials and constructions

            try
            {
                if (typeof(T) == typeof(OpaqueConstruction))
                {
                    return((T)Convert.ChangeType(OpaqueConstructions.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(GlazingConstruction))
                {
                    return((T)Convert.ChangeType(GlazingConstructions.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(OpaqueMaterial))
                {
                    return((T)Convert.ChangeType(OpaqueMaterials.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(GlazingMaterial))
                {
                    return((T)Convert.ChangeType(GlazingMaterials.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(GasMaterial))
                {
                    return((T)Convert.ChangeType(GasMaterials.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(GlazingConstructionSimple))
                {
                    return((T)Convert.ChangeType(GlazingConstructionsSimple.Single(o => o.Name == name), typeof(T)));
                }

                // schedules

                else if (typeof(T) == typeof(DaySchedule))
                {
                    return((T)Convert.ChangeType(DaySchedules.Single(o => o.Name == name), typeof(T)));
                }
                //else if (typeof(T) == typeof(WeekSchedule))
                //{
                //    return (T)Convert.ChangeType(WeekSchedules.Single(o => o.Name == name), typeof(T));
                //}
                else if (typeof(T) == typeof(YearSchedule))
                {
                    return((T)Convert.ChangeType(YearSchedules.Single(o => o.Name == name), typeof(T)));
                }

                else if (typeof(T) == typeof(ScheduleArray))
                {
                    return((T)Convert.ChangeType(ArraySchedules.Single(o => o.Name == name), typeof(T)));
                }

                // zone def

                else if (typeof(T) == typeof(ZoneLoad))
                {
                    return((T)Convert.ChangeType(ZoneLoads.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(ZoneVentilation))
                {
                    return((T)Convert.ChangeType(ZoneVentilations.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(ZoneConstruction))
                {
                    return((T)Convert.ChangeType(ZoneConstructions.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(ZoneConditioning))
                {
                    return((T)Convert.ChangeType(ZoneConditionings.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(DomHotWater))
                {
                    return((T)Convert.ChangeType(DomHotWaters.Single(o => o.Name == name), typeof(T)));
                }
                else if (typeof(T) == typeof(ZoneDefinition))
                {
                    return((T)Convert.ChangeType(ZoneDefinitions.Single(o => o.Name == name), typeof(T)));
                }

                else if (typeof(T) == typeof(WindowSettings))
                {
                    return((T)Convert.ChangeType(WindowSettings.Single(o => o.Name == name), typeof(T)));
                }

                else if (typeof(T) == typeof(FloorDefinition))
                {
                    return((T)Convert.ChangeType(FloorDefinitions.Single(o => o.Name == name), typeof(T)));
                }

                // dont know what this is???

                else
                {
                    return((T)Convert.ChangeType(null, typeof(T)));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Could not find " + name + ": " + ex.Message);
                return(default(T));
            }
        }