EmbeddedResource

Description

sealed class Tinman.Core.EmbeddedResource

The EmbeddedResource class defines a single resource which is embedded in the source code and loaded at runtime via TinmanModule.RegisterResources.

Public / Constructors

Embedded​Resource


public constructor EmbeddedResource → (3)

name in : string

The resource name.

type in : int32

[0..2]
The resource type.

data in : string

[not-empty]
The embedded resource data.

Creates a new instance of EmbeddedResource.

Public / Methods

Generate


public static method Generate → (2)

input in : Path

[not-null]
Path to the input documentation content XML file.

output opt : Path = null

Path to the output source code file. If null, input in will be used, having its suffix replaced with .cs. If Path.Unknown, only the input input in is validated and no source file is generated (its output path is still returned, though).

returns → Path

The path to the generated source file.

Builds a Code-X compliant source code file that contains embedded resources as defined by the XML resource listing.

The XML resource listing must be compatible with this DTD:

<!ELEMENT resources (resource*)>

<!ATTLIST resources namespace CDATA #REQUIRED>
<!ATTLIST resources guid CDATA #REQUIRED>

<!ELEMENT resource EMPTY>
<!ATTLIST resource file CDATA #REQUIRED>
<!ATTLIST resource type (config|file|zip) #REQUIRED>

Use this to associate an XML file with the DTD:

<!DOCTYPE resources PUBLIC "-//TINMAN//CONFIGDOC//EN" "https://dtd.tinman3d.com/EmbeddedResource.dtd">

The namespace attribute must be set to the namespace name of the generated class. The guid attribute must be set to the same value as TinmanModule.Guid. The generated class has an internal static property named Resources, which must be passed to a call to TinmanModule.RegisterResources from within TinmanModule.DoInitialize, for example:

protected override void DoInitialize()
{ RegisterResources(MyModule_Resources.Resources); }

The file attribute must be a path relative to the directory that contains the XML resource listing. The attribute values file, config and zip correspond to the types 0, 1 and 2 of TinmanModule.RegisterResource, respectively.

IOException

If an I/O error has occurred.

ValidatingException

If the XML content is malformed.

Register


public method Register → (1)

module in : TinmanModule

[not-null]
The module to register the resource with.

returns → bool

true if the resource has been registered successfully,
false if an error has occurred (see log message for details).

Registers this embedded resource with the given module in by calling TinmanModule.RegisterResource.