SalResource
Namespace: PPJ.Runtime
Assembly: PPJ.Runtime.50 (5.0.0.0)
Provides resource-name resolution and a common image-loading contract for SAL resources.
- C#
- VB.NET
public class SalResource
Public Class SalResource
Derived classes load icons, bitmaps, or cursors from embedded assembly resources. Resolution first checks the supplied assembly and then the existing manifest-resource cache.
Example:
using PPJ.Runtime;
SalResource resource = new SalResourceImage("Logo.png");
object image = resource.GetImage();
Constructors
SalResource(name, asm)
Resolves an embedded resource using an assembly as the first search location.
| Name | Type | Description |
|---|---|---|
| name | String | The full manifest name or resource-name suffix. Must not be null. |
| asm | Assembly | The assembly to search first, or null to search the existing assembly-resource cache. |
A missing resource leaves Name null and is logged; it does not cause this constructor to fail. Throws:
- ArgumentException The resource name is null.
Properties
Name
String: Gets the resolved manifest resource name.
Methods
FromName(name)
Finds a SAL resource exposed by a resource-container field.
| Parameter | Type | Description |
|---|---|---|
| name | String | The resource field name, optionally qualified by its container type and assembly. |
Returns: SalResource. The resource instance, or null for an empty name or when no matching resource is found.
Uses cached resolutions first. Otherwise, searches public fields of the requested type, or Res and Resources types in loaded PPJ-linked assemblies.
GetImage()
Loads the graphic represented by this resource.
Returns: Object. The graphic supplied by the concrete resource type, or null if loading fails.
The concrete type determines the returned object type and caching behavior.
GetStream()
Opens a stream for the resolved manifest resource.
Returns: Stream. The resource stream. The caller is responsible for disposing it.
Throws:
- Exception The resource has not been resolved or its stream cannot be obtained.