using System;

namespace CareFusion.Mosaic.Interfaces.Types.Components
{
    /// <summary>
    /// Class which represents a Mosaic component's configuration value.
    /// </summary>
    public class ConfigurationValue
    {
        #region Properties

        /// <summary>
        /// Gets or sets the identifier of the Mosaic component this configuration value belongs to.
        /// </summary>
        public int ComponentID { get; set; }

        /// <summary>
        /// Gets or sets the name of the configuration value.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the value of the configuration value.
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// Gets an array of the property names of this object.
        /// These names are required to serialize this object to the database.
        /// </summary>
        public string[] PropertyNames
        {
            get { return new string[] { "ComponentID", "Name", "Value" }; }
        }

        /// <summary>
        /// Gets an array of the raw property values of this object.
        /// These values are required to serialize this object to the database.
        /// </summary>
        public object[] PropertyValues
        {
            get 
            { 
                return new object[] 
                { 
                    this.ComponentID, 
                    this.Name, 
                    (this.Value != null) ? this.Value : (object)DBNull.Value
                }; 
            }
        }

        /// <summary>
        /// Gets an array of the property names which define the unique key of this object.
        /// These names are required to delete this object from the database.
        /// </summary>
        public string[] KeyPropertyNames
        {
            get
            {
                return new string[] { "ComponentID", "Name" };
            }
        }

        /// <summary>
        /// Gets an array of the raw property values which define the unique key of this object.
        /// These names are required to delete this object from the database.
        /// </summary>
        public object[] KeyPropertyValues
        {
            get
            {
                return new object[] { this.ComponentID, this.Name };
            }
        }

        #endregion
      
    }
}
