Esempio n. 1
0
        public void BindData(ITypeDescriptorContext context, object value, object[] attributeArguments)
        {
            filterStandardTypes.Clear();
            if (attributeArguments != null && attributeArguments.Length > 0)
            {
                foreach (Type type in attributeArguments.OfType <Type>().Where(item => iFilterType.IsAssignableFrom(item)))
                {
                    IFilterObjectValueEditorTypes filterTypeObj =
                        (IFilterObjectValueEditorTypes)Activator.CreateInstance(type);
                    filterTypeObj.Initialize(context);
                    filterStandardTypes.Add(filterTypeObj);
                }
            }

            //allowedStandardTypes.AddRange(EnumType<StandartType>.Values);
            IEnumerable <StandartType> _stdTypes = EnumType <StandartType> .Values;

            foreach (var filterStandardTypeObj in filterStandardTypes)
            {
                _stdTypes = filterStandardTypeObj.FilterStandartTypes(_stdTypes);
            }
            allowedStandardTypes.AddRange(_stdTypes);

            PopulateForm();

            ObjectValue  objectValue          = (ObjectValue)value;
            object       objValue             = objectValue.Value;
            StandartType resolvedStandardType = objValue == null ? StandartType.String : StandardValues.ResolveStandardType(objValue.GetType());
            StandartType valueType            = objValue == null ? StandartType.String : resolvedStandardType;

            if (!allowedStandardTypes.Contains(valueType))
            {
                valueType = StandartType.String;
                objValue  = objValue.ToString();
            }

            CurrentValueType = valueType;
            if (objectValue.UseCustomExpression)
            {
                CurrentValueType  = null;
                objValue          = objectValue.CustomExpression;
                valueTextBox.Text = objectValue.CustomExpression;
            }
            else if (objValue != null && valueType == StandartType.String && objValue.GetType() != StandardValues.TYPE_STRING)
            {
                objValue = objValue.ToString();
            }

            this.CurrentValue = objValue;
            UpdateControls();
        }
 public void ShouldGetStandardString()
 {
     var testValue = StandardValues.Get <string>("Foo");
 }