コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Building" /> class.
        /// </summary>
        /// <param name="name">Name of the object used in all simulation engines. Must not contain spaces and use only letters, digits and underscores/dashes. It cannot be longer than 100 characters. (required).</param>
        /// <param name="uniqueStories">An array of unique dragonfly Story objects that together form the entire building. Stories should generally be ordered from lowest floor to highest floor. Note that, if a given Story is repeated several times over the height of the building, the unique story included in this list should be the first (lowest) story of the repeated floors. (required).</param>
        /// <param name="properties">Extension properties for particular simulation engines (Radiance, EnergyPlus). (required).</param>
        /// <param name="displayName">Display name of the object with no restrictions..</param>
        /// <param name="type">type (default to &quot;Building&quot;).</param>
        public Building(string name, List <Story> uniqueStories, BuildingPropertiesAbridged properties, string displayName = default, string type = "Building")
        {
            // to ensure "name" is required (not null)
            if (name == null)
            {
                throw new InvalidDataException("name is a required property for Building and cannot be null");
            }
            else
            {
                this.Name = name;
            }

            // to ensure "uniqueStories" is required (not null)
            if (uniqueStories == null)
            {
                throw new InvalidDataException("uniqueStories is a required property for Building and cannot be null");
            }
            else
            {
                this.UniqueStories = uniqueStories;
            }

            // to ensure "properties" is required (not null)
            if (properties == null)
            {
                throw new InvalidDataException("properties is a required property for Building and cannot be null");
            }
            else
            {
                this.Properties = properties;
            }

            this.DisplayName = displayName;
            // use default value if no "type" provided
            if (type == null)
            {
                this.Type = "Building";
            }
            else
            {
                this.Type = type;
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Building" /> class.
        /// </summary>
        /// <param name="uniqueStories">An array of unique dragonfly Story objects that together form the entire building. Stories should generally be ordered from lowest floor to highest floor. Note that, if a given Story is repeated several times over the height of the building, the unique story included in this list should be the first (lowest) story of the repeated floors. (required).</param>
        /// <param name="properties">Extension properties for particular simulation engines (Radiance, EnergyPlus). (required).</param>
        /// <param name="identifier">Text string for a unique object ID. This identifier remains constant as the object is mutated, copied, and serialized to different formats (eg. dict, idf, rad). This identifier is also used to reference the object across a Model. It must be &lt; 100 characters and not contain any spaces or special characters. (required).</param>
        /// <param name="displayName">Display name of the object with no character restrictions..</param>
        /// <param name="userData">Optional dictionary of user data associated with the object.All keys and values of this dictionary should be of a standard data type to ensure correct serialization of the object (eg. str, float, int, list)..</param>
        public Building
        (
            string identifier, List <Story> uniqueStories, BuildingPropertiesAbridged properties, // Required parameters
            string displayName = default, Object userData = default                               // Optional parameters
        ) : base(identifier: identifier, displayName: displayName, userData: userData)            // BaseClass
        {
            // to ensure "uniqueStories" is required (not null)
            this.UniqueStories = uniqueStories ?? throw new ArgumentNullException("uniqueStories is a required property for Building and cannot be null");
            // to ensure "properties" is required (not null)
            this.Properties = properties ?? throw new ArgumentNullException("properties is a required property for Building and cannot be null");

            // Set non-required readonly properties with defaultValue
            this.Type = "Building";

            // check if object is valid
            if (this.GetType() == typeof(Building))
            {
                this.IsValid(throwException: true);
            }
        }