import { Schema } from "@itwin/ecschema-metadata";
export class IModelSchemaLocater {
    _iModel;
    constructor(iModel) {
        this._iModel = iModel;
    }
    async getSchema(schemaKey, matchType, context) {
        await this.getSchemaInfo(schemaKey, matchType, context);
        const schema = await context.getCachedSchema(schemaKey, matchType);
        return schema;
    }
    async getSchemaInfo(schemaKey, _matchType, context) {
        try {
            const schemaJson = this._iModel.getSchemaProps(schemaKey.name);
            return await Schema.startLoadingFromJson(schemaJson, context);
        }
        catch (e) {
            if (e.errorNumber === 65574)
                return undefined;
            throw e;
        }
    }
    getSchemaSync(schemaKey, _matchType, context) {
        try {
            const schemaJson = this._iModel.getSchemaProps(schemaKey.name);
            const schema = Schema.fromJsonSync(schemaJson, context);
            return schema;
        }
        catch (e) {
            if (e.errorNumber === 65574)
                return undefined;
            throw e;
        }
    }
}
//# sourceMappingURL=IModelSchemaLocater.js.map