Skip to content

net90_PropertyGridHelpers.Attributes_ResourcePathAttribute

dparvin edited this page Jan 11, 2026 · 14 revisions

ResourcePathAttribute class

Specifies the location of a resource type (e.g., strings, images, cursors) to be used in conjunction with UI editors, type converters, or design-time attributes.

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Property, 
    AllowMultiple = true)]
public class ResourcePathAttribute : Attribute
parameter description
resourcePath The fully qualified name of the resource class (e.g., "MyApp.Resources.MyStrings").
resourceAssembly Optional assembly name containing the resource. If null, defaults to the calling assembly.
resourceUsage Optional usage flag to indicate what the resource is used for (e.g., strings, images). Defaults to All.

Public Members

name description
ResourcePathAttribute(…) Specifies the location of a resource type (e.g., strings, images, cursors) to be used in conjunction with UI editors, type converters, or design-time attributes.
static Get(…) Resolves the most appropriate ResourcePathAttribute for the given context and usage.
ResourceAssembly { get; } Gets the resource assembly.
ResourcePath { get; } Gets the resource path associated with the property or enum value.
ResourceUsage { get; } Gets the intended usage for the resource path (e.g., Strings or Images). Used to filter multiple attributes for different purposes.
GetAssembly() Resolves the assembly object from the stored assembly name.

Remarks

This attribute can be applied to properties, enum types, or classes to associate them with a strongly-typed resource class (e.g., Properties.Resources). The optional ResourceUsage flag allows specifying what the path is used for, enabling separation of string resources, image resources, and more. If multiple ResourcePathAttributes are applied, the resolution order is:

  1. Property-level attributes
  2. Enum type or property type-level attributes
  3. Class-level attributes (declaring type)

Examples

Example 1: Use for enum text

[ResourcePath("MyNamespace.MyEnumResources", resourceUsage: ResourceUsage.Strings)]
public enum ButtonType
{
    [EnumText("Primary")]
    Primary,
    [EnumText("Secondary")]
    Secondary
}

Example 2: Separate image path for UI editor

[ResourcePath("MyNamespace.ButtonImages", resourceUsage: ResourceUsage.Images)]
public enum ButtonType { ... }

See Also

Clone this wiki locally