@itwin/ecschema-metadata
Version:
ECObjects core concepts in typescript
35 lines • 1.71 kB
TypeScript
import { SchemaContext } from "./Context";
import { Schema } from "./Metadata/Schema";
import { SchemaPropsGetter } from "./SchemaJsonLocater";
/**
* A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.
* Loaded schemas are held in memory within a schema context managed by SchemaLoader.
* The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
* is a possibility, thereby avoiding unnecessary schema retrievals from the function.
*
* Since the development of this class, the IModelDb class has been enhanced to include a schema context.
* In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.
*
* ** Example **
* ```ts
* [[include:IModelSchemas.loadFromDb]]
* ```
* @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.
*/
export declare class SchemaLoader {
private _context;
constructor(getSchema: SchemaPropsGetter);
/** Get a schema by name
* @param schemaName a string with the name of the schema to load.
* @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.
*/
getSchema(schemaName: string): Schema;
/** Attempts to get a schema by name
* @param schemaName a string with the name of the schema to load.
* @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.
*/
tryGetSchema(schemaName: string): Schema | undefined;
/** Gets the SchemaContext used by the loader. */
get context(): SchemaContext;
}
//# sourceMappingURL=SchemaLoader.d.ts.map