/// <summary> /// Gets a collection of standard values collection for a System.Globalization.CultureInfo /// object using the specified context. /// </summary> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (_values == null) { CultureInfo[] installedCultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures | CultureTypes.NeutralCultures); int invariantIndex = Array.IndexOf(installedCultures, CultureInfo.InvariantCulture); CultureInfo[] array; if (invariantIndex != -1) { Debug.Assert(invariantIndex >= 0 && invariantIndex < installedCultures.Length); installedCultures[invariantIndex] = null; array = new CultureInfo[installedCultures.Length]; } else { array = new CultureInfo[installedCultures.Length + 1]; } Array.Copy(installedCultures, array, installedCultures.Length); Array.Sort(array, new CultureComparer(this)); Debug.Assert(array[0] == null); if (array[0] == null) { //we replace null with the real default culture because there are code paths // where the propgrid will send values from this returned array directly -- instead // of converting it to a string and then back to a value (which this relied on). array[0] = CultureInfo.InvariantCulture; //null isn't the value here -- invariantculture is. } _values = new StandardValuesCollection(array); } return(_values); }
/// <include file='doc\CultureInfoConverter.uex' path='docs/doc[@for="CultureInfoConverter.GetStandardValues"]/*' /> /// <devdoc> /// <para> /// Gets a collection of standard values collection for a System.Globalization.CultureInfo /// object using the specified context. /// </para> /// </devdoc> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (values == null) { CultureInfo[] installedCultures = CultureInfo.GetCultures(CultureTypes.AllCultures); ArrayList cultureList = new ArrayList(); // populate the array with the default culture, which is NULL // cultureList.Add(null); // Now populate it with the installed cultures. // for (int index = 0; index < installedCultures.Length; ++index) { cultureList.Add(installedCultures[index]); } ArrayList.Adapter(cultureList).Sort(new CultureComparer()); values = new StandardValuesCollection(cultureList.ToArray()); } return(values); }
/// <devdoc> /// <para>Gets a collection of standard values /// for the Boolean data type.</para> /// </devdoc> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (values == null) { values = new StandardValuesCollection(new object[] { true, false }); } return(values); }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (stdValues == null) { Array values = Enum.GetValues(type); Array.Sort(values); stdValues = new StandardValuesCollection(values); } return(stdValues); }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (_standardValues == null) { CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); Array.Sort(cultures, new CultureInfoComparer()); CultureInfo[] stdValues = new CultureInfo[cultures.Length + 1]; stdValues[0] = CultureInfo.InvariantCulture; Array.Copy(cultures, 0, stdValues, 1, cultures.Length); _standardValues = new StandardValuesCollection(stdValues); } return(_standardValues); }
/// <returns>A <see cref="T:System.ComponentModel.TypeConverter.StandardValuesCollection" /> that holds a standard set of valid values, or null if the data type does not support a standard set of values.</returns> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be null.</param> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (underlyingTypeConverter != null && underlyingTypeConverter.GetStandardValuesSupported(context)) { StandardValuesCollection standardValues = underlyingTypeConverter.GetStandardValues(context); if (standardValues != null) { ArrayList arrayList = new ArrayList(standardValues); arrayList.Add(null); return(new StandardValuesCollection(arrayList)); } } return(base.GetStandardValues(context)); }
/// <include file='doc\EnumConverter.uex' path='docs/doc[@for="EnumConverter.GetStandardValues"]/*' /> /// <internalonly/> /// <devdoc> /// <para>Gets a collection of standard values for the data type this validator is /// designed for.</para> /// </devdoc> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (values == null) { Array objValues = Enum.GetValues(type); IComparer comparer = Comparer; if (comparer != null) { Array.Sort(objValues, 0, objValues.Length, comparer); } values = new StandardValuesCollection(objValues); } return(values); }
// Return a collection of standard values for this data type. public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context) { if (standardValues != null) { return(standardValues); } Array array = Enum.GetValues(type); IComparer comparer = Comparer; if (comparer != null) { Array.Sort(array, 0, array.Length, comparer); } standardValues = new StandardValuesCollection(array); return(standardValues); }
/// <internalonly/> /// <summary> /// <para>Gets a collection of standard values for the data type this validator is designed for.</para> /// </summary> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (_values == null) { object[] objTypes; if (_types != null) { objTypes = new object[_types.Length]; Array.Copy(_types, objTypes, _types.Length); } else { objTypes = null; } _values = new StandardValuesCollection(objTypes); } return(_values); }
/// <summary> /// Gets a collection of standard values for the data type this type converter is designed for. /// </summary> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (UnderlyingTypeConverter != null) { StandardValuesCollection values = UnderlyingTypeConverter.GetStandardValues(context); if (GetStandardValuesSupported(context) && values != null) { // Create a set of standard values around nullable instances. object[] wrappedValues = new object[values.Count + 1]; int idx = 0; wrappedValues[idx++] = null; foreach (object value in values) { wrappedValues[idx++] = value; } return(new StandardValuesCollection(wrappedValues)); } } return(base.GetStandardValues(context)); }
/// <internalonly/> /// <devdoc> /// <para>Gets a collection of standard values for the data type this validator is /// designed for.</para> /// </devdoc> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (values == null) { // We need to get the enum values in this rather round-about way so we can filter // out fields marked Browsable(false). Note that if multiple fields have the same value, // the behavior is undefined, since what we return are just enum values, not names. Type reflectType = TypeDescriptor.GetReflectionType(type); if (reflectType == null) { reflectType = type; } FieldInfo[] fields = reflectType.GetFields(BindingFlags.Public | BindingFlags.Static); ArrayList objValues = null; if (fields != null && fields.Length > 0) { objValues = new ArrayList(fields.Length); } if (objValues != null) { foreach (FieldInfo field in fields) { BrowsableAttribute browsableAttr = null; foreach (Attribute attr in field.GetCustomAttributes(typeof(BrowsableAttribute), false)) { browsableAttr = attr as BrowsableAttribute; } if (browsableAttr == null || browsableAttr.Browsable) { object value = null; try { if (field.Name != null) { value = Enum.Parse(type, field.Name); } } catch (ArgumentException) { // Hmm, for some reason, the parse threw. Let us ignore this value. } if (value != null) { objValues.Add(value); } } } IComparer comparer = Comparer; if (comparer != null) { objValues.Sort(comparer); } } Array arr = (objValues != null) ? objValues.ToArray() : null; values = new StandardValuesCollection(arr); } return(values); }
/// <summary> /// Gets a collection of standard values for the Boolean data type. /// </summary> public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return(s_values ?? (s_values = new StandardValuesCollection(new object[] { true, false }))); }