import { GlobalContext } from './GlobalContext';
import mindSporeLite from '@ohos.ai.mindSporeLite';
import common from '@ohos.app.ability.common';
import { BusinessError } from '@ohos.base';
export class Test {
value: number = 0;
foo(): void {
GlobalContext.getContext().setObject("value", this.value);
}
}
export async function testMSL() {
let value: number = 0;
GlobalContext.getContext().setObject("value", value);
let globalContext = GlobalContext.getContext().getObject("value") as common.UIAbilityContext;
let inputBuffer: ArrayBuffer | null = null;
let inputName: string = 'add.bin';
console.log('========win',globalContext)
try {
globalContext.resourceManager.getRawFileContent(inputName)
.then((value: Uint8Array) => {
inputBuffer = value.buffer;
})
.catch((error: BusinessError) => {
console.error("========getRawFileContent promise error is " + error);
});
} catch (error) {
let code = (error as BusinessError).code;
let message = (error as BusinessError).message;
let data=(error as BusinessError).data;
let name=(error as BusinessError).name;
let stack=(error as BusinessError).stack;
console.error(`========promise getRawFileContent failed, error code: ${code}, message: ${message},data{data},name=${name},stack=${stack}`);
}