/// <summary>
        /// When overridden in a derived class, gets the current value of the property on a component.
        /// </summary>
        /// <param name="component">The component with the property for which to retrieve the value.</param>
        /// <returns>
        /// The value of a property for a given component.
        /// </returns>
        public override object GetValue(object component)
        {
            // Have the property bag raise an event to get the current value of the property.
            PropertySpecificationEventArgs e = new PropertySpecificationEventArgs(_specification, null);

            _containingBag.OnGetValue(e);
            if (_specification != null)
            {
                if (e.Value == null)
                {
                    if (_specification.DefaultValue != null)
                    {
                        e.Value = _specification.DefaultValue;
                    }
                }
                else
                {
                    if (_specification.PropertyType.IsEnum)
                    {
                        e.Value = Enum.ToObject(_specification.PropertyType, e.Value);
                    }
                }
            }
            return(e.Value);
        }
        /// <summary>
        /// When overridden in a derived class, sets the value of the component to a different value.
        /// </summary>
        /// <param name="component">The component with the property value that is to be set.</param>
        /// <param name="value">The new value.</param>
        public override void SetValue(object component, object value)
        {
            // Have the property bag raise an event to set the current value of the property.
            object valueToUse = value;

            if (_specification != null)
            {
                if (_specification.PropertyType == typeof(string))
                {
                    if (_specification.ConvertEmptyStringToNull && ((valueToUse as string) == string.Empty))
                    {
                        valueToUse = null;
                    }
                }
                else
                {
                    if (_specification.PropertyType.IsEnum)
                    {
                        valueToUse = Convert.ToInt32(valueToUse);
                    }
                }
            }
            PropertySpecificationEventArgs e = new PropertySpecificationEventArgs(_specification, valueToUse);

            _containingBag.OnSetValue(e);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Raises the SetValue event, if ValueGetterFunc is left null, otherwise it will call ValueGetterFunc instead.
 /// </summary>
 /// <param name="e">A PropertySpecEventArgs that contains the event data.</param>
 protected internal virtual void OnSetValue(PropertySpecificationEventArgs e)
 {
     if (this.ValueSetterFunc == null)
     {
         this.SetValue.RaiseEvent(this, e);
     }
     else
     {
         this.ValueSetterFunc(e.Property.Name, e.Value);
     }
 }
Ejemplo n.º 4
0
		/// <summary>
		/// Raises the GetValue event, if ValueGetterFunc is left null, otherwise it will call ValueGetterFunc instead. 
		/// </summary>
		/// <param name="e">A PropertySpecEventArgs that contains the event data.</param>
		protected internal virtual void OnGetValue(PropertySpecificationEventArgs e)
		{
			if(this.ValueGetterFunc == null)
			{
				this.GetValue.RaiseEvent(this, e);
			}
			else
			{
				e.Value = this.ValueGetterFunc(e.Property.Name);
			}
		}
 /// <summary>
 /// When overridden in a derived class, sets the value of the component to a different value.
 /// </summary>
 /// <param name="component">The component with the property value that is to be set.</param>
 /// <param name="value">The new value.</param>
 public override void SetValue(object component, object value)
 {
     // Have the property bag raise an event to set the current value of the property.
     object valueToUse = value;
     if(_specification!=null)
     {
         if(_specification.PropertyType == typeof(string))
         {
             if(_specification.ConvertEmptyStringToNull && ((valueToUse as string) == string.Empty))
             {
                 valueToUse = null;
             }
         }
         else
         {
             if(_specification.PropertyType.IsEnum)
             {
                 valueToUse = Convert.ToInt32(valueToUse);
             }
         }
     }
     PropertySpecificationEventArgs e = new PropertySpecificationEventArgs(_specification, valueToUse);
     _containingBag.OnSetValue(e);
 }
 /// <summary>
 /// When overridden in a derived class, gets the current value of the property on a component.
 /// </summary>
 /// <param name="component">The component with the property for which to retrieve the value.</param>
 /// <returns>
 /// The value of a property for a given component.
 /// </returns>
 public override object GetValue(object component)
 {
     // Have the property bag raise an event to get the current value of the property.
     PropertySpecificationEventArgs e = new PropertySpecificationEventArgs(_specification, null);
     _containingBag.OnGetValue(e);
     if(_specification != null)
     {
         if(e.Value == null)
         {
             if(_specification.DefaultValue != null)
             {
                 e.Value = _specification.DefaultValue;
             }
         }
         else
         {
             if(_specification.PropertyType.IsEnum)
             {
                 e.Value = Enum.ToObject(_specification.PropertyType, e.Value);
             }
         }
     }
     return e.Value;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// This member overrides PropertyBag.OnSetValue.
 /// </summary>
 protected internal override void OnSetValue(PropertySpecificationEventArgs e)
 {
     this[e.Property.Name] = e.Value;
     base.OnSetValue(e);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// This member overrides PropertyBag.OnSetValue.
 /// </summary>
 protected internal override void OnSetValue(PropertySpecificationEventArgs e)
 {
     this[e.Property.Name] = e.Value;
     base.OnSetValue(e);
 }