net90_PropertyGridHelpers.Support_Support_GetResourcePath - dparvin/PropertyGridHelpers GitHub Wiki

Support.GetResourcePath method

Determines the resource path based on the specified property or related data type.

public static string GetResourcePath(ITypeDescriptorContext context, Type type)
parameter description
context The type descriptor context, which provides metadata about the property and its container.
type The data type associated with the resource, typically an enum or a property type.

Return Value

A string containing the resource path based on the provided property or type. If no applicable attributes are found, the method returns the default resource path: "Properties.Resources".

Exceptions

exception condition
ArgumentNullException Thrown if type is null.

Remarks

This method searches for the resource path using the following order of precedence:

  1. If the property has a DynamicPathSourceAttribute, it retrieves the path from the referenced property specified in the attribute.
  2. If the property has a ResourcePathAttribute, it uses the specified path.
  3. If the type (or its underlying nullable type) is an enumeration and has a ResourcePathAttribute, it uses the path defined by the attribute.
  4. If none of the above conditions are met, it defaults to "Properties.Resources".

Examples

Example usage:

 [ResourcePath("Custom.Resources")] public enum MyEnum { Value1, Value2 }  string path
            = GetResourcePath(null, typeof(MyEnum)); Console.WriteLine(path); // Outputs: "Custom.Resources"

See Also

⚠️ **GitHub.com Fallback** ⚠️