@jaricardodev/ews-javascript-api
Version:
EWS Managed api in JavaScript
39 lines (34 loc) • 1.39 kB
text/typescript
export class LazyMember<T> {
get Member(): T {
if (!this.initialized) {
//lock(this.lockObject)
//{
if (!this.initialized) {
this.lazyMember = this.initializationDelegate();
}
this.initialized = true;
//}
}
return this.lazyMember;
}
private lazyMember: T;
private initializationDelegate: InitializeLazyMember<T>;//() => T;
private lockObject: any;
private initialized: boolean = false;
/// <summary>
/// Constructor
/// </summary>
/// <param name="initializationDelegate">The initialization delegate to call for the item on first access
/// </param>
constructor(initializationDelegate: InitializeLazyMember<T>) {
this.initializationDelegate = initializationDelegate;
}
}
export interface InitializeLazyMember<T> {
(): T;
//export class InitializeLazyMember<T> extends System.MulticastDelegate {
// BeginInvoke(callback: System.AsyncCallback, object: any): System.IAsyncResult{ throw new Error("LazyMember.ts - BeginInvoke : Not implemented.");}
// EndInvoke(result: System.IAsyncResult): T{ throw new Error("LazyMember.ts - EndInvoke : Not implemented.");}
// Invoke(): T{ throw new Error("LazyMember.ts - Invoke : Not implemented.");}
//}
}