public WhiskeyPropertyContainer(WhiskeyProperty prop) { WhiskeyProperty = prop; Name = prop.Name; //testTypeName = "poop"; //TypeName = prop.TypeVal.TypeName; Value = prop.TypeVal.Value; //prop.TypeVal.ValueChanged += (s, a) => //{ // Changed(this, new WhiskeyPropertyEventArgs(WhiskeyProperty)); //}; }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value.GetType() == typeof(string)) { PropertyAdapter adapter = (PropertyAdapter)context.Instance; string name = context.PropertyDescriptor.Name; GeneralPropertyDescriptor gpd = (GeneralPropertyDescriptor)context.PropertyDescriptor; WhiskeyProperty whiskeyProp = adapter.WhiskeyPropertys.Where((w) => { return(w.Name.Equals(name)); }).ToList()[0]; Type toType = whiskeyProp.TypeVal.Value.GetType(); TypeConverter converter = WhiskeyTypeConverters.lookUp(toType.Name); if (converter != null && value != null && converter.CanConvertFrom(value.GetType())) { object converted = converter.ConvertFrom(context, culture, value); whiskeyProp.TypeVal.Value = converted; } if (ConverterManager.Instance.hasConverter(toType)) { whiskeyProp.TypeVal.Value = ConverterManager.Instance.convertFromString(toType, (string)value); } else { try { whiskeyProp.TypeVal.Value = Convert.ChangeType(value, toType); } catch (Exception e) { //??? } } return(gpd.PropValue); } return(base.ConvertFrom(context, culture, value)); }
public WhiskeyPropertyContainerSecured(WhiskeyProperty prop) : base(prop) { }
public WhiskeyPropertyEventArgs(WhiskeyProperty prop) { WhiskeyProperty = prop; }