addResource method
void
addResource(
- String fullName,
- RT resource
)
Implementation
void addResource(String fullName, RT resource) {
if (!path.isAbsolute(fullName)) {
throw HTError.notAbsoluteError(fullName);
}
for (final context in contexts) {
final normalized = context.getAbsolutePath(key: fullName);
if (context.contains(normalized)) {
_cachedSources[fullName] = resource;
if (onRootsUpdated != null) {
onRootsUpdated!();
}
return;
}
}
final root = path.dirname(fullName);
final context = createContext(root);
_contextRoots[context.root] = context;
final normalized = context.getAbsolutePath(key: fullName);
context.addResource(normalized, resource);
_cachedSources[fullName] = resource;
if (onRootsUpdated != null) {
onRootsUpdated!();
}
}