net90_PropertyGridHelpers.Support_Support_GetResourcePath - dparvin/PropertyGridHelpers GitHub Wiki
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. |
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"
.
exception | condition |
---|---|
ArgumentNullException | Thrown if type is null . |
This method searches for the resource path using the following order of precedence:
- If the property has a
DynamicPathSourceAttribute
, it retrieves the path from the referenced property specified in the attribute. - If the property has a
ResourcePathAttribute
, it uses the specified path. - If the type (or its underlying nullable type) is an enumeration and has a
ResourcePathAttribute
, it uses the path defined by the attribute. - If none of the above conditions are met, it defaults to
"Properties.Resources"
.
Example usage:
[ResourcePath("Custom.Resources")] public enum MyEnum { Value1, Value2 } string path
= GetResourcePath(null, typeof(MyEnum)); Console.WriteLine(path); // Outputs: "Custom.Resources"
- class Support
- namespace PropertyGridHelpers.Support
- assembly PropertyGridHelpers