Esempio n. 1
0
        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));
        }
Esempio n. 3
0
 public WhiskeyPropertyContainerSecured(WhiskeyProperty prop)
     : base(prop)
 {
 }
Esempio n. 4
0
 public WhiskeyPropertyEventArgs(WhiskeyProperty prop)
 {
     WhiskeyProperty = prop;
 }