public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            string val = value as string;

            val = val.ToLowerInvariant();
            string[] options = val.Split('|');
            UiControlTypeSelectorMode mode = new UiControlTypeSelectorMode();
            foreach (string opt in options)
            {
                string option = opt.Trim();
                if (option == TypeIncludes.ConcreteTypes.ToString().ToLowerInvariant())
                {
                    mode = mode | UiControlTypeSelectorMode.ConcreteTypes;
                }
                else if (option == TypeIncludes.InterfaceTypes.ToString().ToLowerInvariant())
                {
                     mode = mode | UiControlTypeSelectorMode.InterfaceTypes;
                }
                else if (option == TypeIncludes.PrimitiveTypes.ToString().ToLowerInvariant())
                {
                     mode = mode | UiControlTypeSelectorMode.PrimitiveTypes;
                }
                else
                {
                    throw new FormatException(String.Format("{0} is not a valid TextSelector Mode value - use ConcreteTypes, InterfaceTypes, PrimitiveTypes", value));
                }
            }
            return mode;
        }
示例#2
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            string val = value as string;

            val = val.ToLowerInvariant();
            string[] options = val.Split('|');
            UiControlTypeSelectorMode mode = new UiControlTypeSelectorMode();

            foreach (string opt in options)
            {
                string option = opt.Trim();
                if (option == TypeIncludes.ConcreteTypes.ToString().ToLowerInvariant())
                {
                    mode = mode | UiControlTypeSelectorMode.ConcreteTypes;
                }
                else if (option == TypeIncludes.InterfaceTypes.ToString().ToLowerInvariant())
                {
                    mode = mode | UiControlTypeSelectorMode.InterfaceTypes;
                }
                else if (option == TypeIncludes.PrimitiveTypes.ToString().ToLowerInvariant())
                {
                    mode = mode | UiControlTypeSelectorMode.PrimitiveTypes;
                }
                else
                {
                    throw new FormatException(String.Format("{0} is not a valid TextSelector Mode value - use ConcreteTypes, InterfaceTypes, PrimitiveTypes", value));
                }
            }
            return(mode);
        }
 private static bool IsSet(UiControlTypeSelectorMode flags, UiControlTypeSelectorMode compareFlag)
 {
     return ((flags & compareFlag) == compareFlag);
 }
示例#4
0
 private static bool IsSet(UiControlTypeSelectorMode flags, UiControlTypeSelectorMode compareFlag)
 {
     return((flags & compareFlag) == compareFlag);
 }