ResourceExplorer class
Class which gives standard access to content resources.
Constructors
Resource |
Initializes a new instance of the ResourceExplorer class. |
Resource |
Initializes a new instance of the ResourceExplorer class. |
Properties
changed | Event which fires when a resource is changed. |
resource |
Gets resource providers. |
resource |
Gets resource type id extensions managed by resource explorer. |
Methods
add |
Add a folder resource. |
add |
Add folder resources. |
add |
Add a resource provider to the resources managed by resource explorer. |
add |
Add a resource type to resource type set. |
build |
Build type for given $kind from configuration. |
get |
Gets resource by id. |
get |
Get resources of a given type extension. |
load |
Load type from resource |
load |
Load type from resource |
refresh() | Reload any cached data. |
register |
Register a declarative type with the resource loader system. |
Constructor Details
ResourceExplorer(ResourceExplorerOptions)
Initializes a new instance of the ResourceExplorer class.
new ResourceExplorer(options?: ResourceExplorerOptions)
Parameters
- options
- ResourceExplorerOptions
The configuration options.
ResourceExplorer(ResourceProvider[])
Initializes a new instance of the ResourceExplorer class.
new ResourceExplorer(providers: ResourceProvider[])
Parameters
- providers
The list of ResourceProvider to initialize the current instance.
Property Details
changed
Event which fires when a resource is changed.
any changed
Property Value
any
resourceProviders
resourceTypes
Gets resource type id extensions managed by resource explorer.
resourceTypes: Set<string>
Property Value
Set<string>
Method Details
addFolder(string, boolean, boolean)
Add a folder resource.
function addFolder(folder: string, includeSubFolders?: boolean, monitorChanges?: boolean): ResourceExplorer
Parameters
- folder
-
string
Folder to be included as a resource.
- includeSubFolders
-
boolean
Whether to include subfolders.
- monitorChanges
-
boolean
Whether to track changes.
Returns
Resource explorer so that you can fluently call multiple methods on the resource explorer.
addFolders(string, string[], boolean)
Add folder resources.
function addFolders(folder: string, ignoreFolders?: string[], monitorChanges?: boolean): ResourceExplorer
Parameters
- folder
-
string
Collection of folders to be included as resources.
- ignoreFolders
-
string[]
Imediate subfolders to ignore.
- monitorChanges
-
boolean
Whether to track changes.
Returns
Resource explorer so that you can fluently call multiple methods on the resource explorer.
addResourceProvider(ResourceProvider)
Add a resource provider to the resources managed by resource explorer.
function addResourceProvider(resourceProvider: ResourceProvider): ResourceExplorer
Parameters
- resourceProvider
- ResourceProvider
Resource provider to be added.
Returns
Resource explorer so that you can fluently call multiple methods on the resource explorer.
addResourceType(string)
Add a resource type to resource type set.
function addResourceType(type: string)
Parameters
- type
-
string
Resource type.
buildType<T, C>(string, C)
Build type for given $kind from configuration.
function buildType<T, C>(kind: string, config: C): T
Parameters
- kind
-
string
$kind.
- config
-
C
Source configuration object.
Returns
T
Instantiated object.
getResource(string)
Gets resource by id.
function getResource(id: string): Resource
Parameters
- id
-
string
Resource id.
Returns
The resource, or undefined if not found.
getResources(string)
Get resources of a given type extension.
function getResources(fileExtension: string): Resource[]
Parameters
- fileExtension
-
string
File extension filter.
Returns
Resource[]
The resources.
loadType<T>(Resource)
Load type from resource
function loadType<T>(resource: Resource): T
Parameters
- resource
- Resource
Resource id to bind to.
Returns
T
Type created from resource.
loadType<T>(string)
Load type from resource
function loadType<T>(resourceId: string): T
Parameters
- resourceId
-
string
Resource id to bind to.
Returns
T
Type created from resource
refresh()
Reload any cached data.
function refresh()
registerType<T>(string, Newable<T>, CustomDeserializer<T, Record<string, unknown>>)
Register a declarative type with the resource loader system.
function registerType<T>(kind: string, type: Newable<T>, loader?: CustomDeserializer<T, Record<string, unknown>>): ResourceExplorer
Parameters
- kind
-
string
The $kind name to map to this type.
- type
-
Newable<T>
Type of object to create.
- loader
-
CustomDeserializer<T, Record<string, unknown>>
Optional custom deserializer.
Returns
Resource explorer for fluent style multiple calls.