Skip to main content
Version: 2025

SalResource

Namespace: PPJ.Runtime

Assembly: PPJ.Web.50 (5.0.0.0)

Locates an embedded assembly resource and loads its image on demand.

public class SalResource

Resource resolution first checks the supplied assembly and then assemblies whose manifest resources have already been cached. Full names and case-insensitive name suffixes are accepted. Image loading is cached, including failures.

Example:

using PPJ.Runtime;

SalResource resource = new SalResource(
"Logo.png", System.Reflection.Assembly.GetExecutingAssembly());
System.Drawing.Image image = resource.GetImage();
// A missing resource or an invalid image produces null.

Constructors

Instance member SalResource(name, asm)

Resolves an embedded resource using an assembly as the first search location.

NameTypeDescription
nameStringThe full manifest name or resource-name suffix. Must not be null.
asmAssemblyThe 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:

Properties

Instance member Name

String: Gets the resolved manifest resource name.

Methods

Static member FromName(name)

Finds a SAL resource exposed by a resource-container field.

ParameterTypeDescription
nameStringThe 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.

Instance member GetImage()

Loads and caches a bitmap from the resolved resource.

Returns: Image. The cached image, or null if the image could not be loaded.

The first load attempt is cached. Loading exceptions are logged and converted to a null result. Repeated calls return the same image reference.

Instance member 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.