예제 #1
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;
        }
예제 #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);
        }
예제 #3
0
 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);
 }