projects/wms-framework/src/lib/wcfserviceinvocationsupport/ClientBase.ts
ClientBase class
Properties |
|
Methods |
Accessors |
constructor(p1?: any, p2?: any)
|
_channel |
Type : T
|
Public binding |
Type : CommunicationBinding
|
Public Endpoint |
Type : any
|
Default value : null
|
Public InnerChannel |
Default value : new InnerChannel()
|
Public serviceName |
Type : string
|
Default value : null
|
Public url |
Type : string
|
Default value : null
|
Abort |
Abort()
|
Causes the ClientBase object to transition immediately from its current state into the closed state.
Returns :
void
|
BeginClose | |||||||||
BeginClose(callback: AsyncCallback, asyncState: any)
|
|||||||||
BeginClose method
Parameters :
Returns :
IAsyncResult
{IAsyncResult} |
BeginCloseWithTimeout | ||||||||||||
BeginCloseWithTimeout(timeout: TimeRange, callback: AsyncCallback, asyncState: any)
|
||||||||||||
BeginCloseWithTimeout method
Parameters :
Returns :
IAsyncResult
{IAsyncResult} |
BeginOpen | |||||||||
BeginOpen(callback: AsyncCallback, asyncState: any)
|
|||||||||
BeginOpen method.
Parameters :
Returns :
IAsyncResult
{IAsyncResult} |
BeginOpenWithTimeout | ||||||||||||
BeginOpenWithTimeout(timeout: TimeRange, callback: AsyncCallback, asyncState: any)
|
||||||||||||
BeginOpenWithTimeout method
Parameters :
Returns :
IAsyncResult
{IAsyncResult} |
Close | ||||||
Close(timeout: number)
|
||||||
Close method
Parameters :
Returns :
void
|
CloseWithTimeout | ||||||
CloseWithTimeout(timeout: TimeRange)
|
||||||
CloseWithTimeout method
Parameters :
Returns :
void
|
EndClose | ||||||
EndClose(result: IAsyncResult)
|
||||||
EndClose method
Parameters :
Returns :
void
|
EndOpen | ||||||
EndOpen(result: IAsyncResult)
|
||||||
EndOpen method
Parameters :
Returns :
void
|
Public InvokeAsync | ||||||||||||||||||
InvokeAsync(beginOperationCallback: (v1: any[],v2: AsyncCallback,v3: any) => void, inputValue: any[], endOperationCallback: (v1: IAsyncResult) => void, operationCompletedCallback: (v1: any) => void, userState: any)
|
||||||||||||||||||
Invokes service method
Parameters :
Returns :
any
{*} |
Open | ||||||
Open(timeout: number)
|
||||||
Open method
Parameters :
Returns :
void
|
OpenWithTimeout | ||||||
OpenWithTimeout(timeout: TimeRange)
|
||||||
OpenWithTimeout method
Parameters :
Returns :
void
|
Binding |
getBinding()
|
Gets the protocol used to handle the messages between client and server
Returns :
CommunicationBinding
|
HttpClientToUse | ||||||
getHttpClientToUse()
|
||||||
Getter for exclusive HttpClient to use with this client object
Returns :
HttpClient
|
||||||
setHttpClientToUse(client: HttpClient)
|
||||||
Sets an exclusive HttpClient to use for this client
Parameters :
Returns :
void
|
Channel | ||||||
getChannel()
|
||||||
setChannel(value: T)
|
||||||
Parameters :
Returns :
void
|
import {
ICommunicationObject,
CommunicationBinding,
} from './CommunicationSupport';
import { AsyncCallback, IAsyncResult } from './AsyncResultSupport';
import { EndpointAddress } from './EndpointAddress';
import { HttpClient } from '@angular/common/http';
import { Debugger } from '../diagnostics/Debugger';
import { InnerChannel } from './InnerChannel';
import { TimeRange } from '../baseframework';
import { WcfCustomBinding } from './channels';
/**
* ClientBase class
*
* @export
* @class ClientBase
* @implements {ICommunicationObject}
* @template T
* @wType System.ServiceModel.ClientBase`1
*/
export class ClientBase<T> implements ICommunicationObject {
public serviceName: string = null;
public url: string = null;
public InnerChannel = new InnerChannel();
public Endpoint: any = null;
public binding: CommunicationBinding;
#_channel: T;
/**
* Gets the protocol used to handle the messages between client and server
*
* @readonly
* @type {CommunicationBinding}
* @memberof ClientBase
* @wIgnore
*/
get Binding(): CommunicationBinding {
return this.binding;
}
/**
* Getter for exclusive HttpClient to use with this client object
*
* @type {HttpClient}
* @memberof ClientBase
* @wIgnore
*/
get HttpClientToUse(): HttpClient {
return (this.Channel as any)?.HttpClient;
}
/**
* Sets an exclusive HttpClient to use for this client
*
* @memberof ClientBase
* @wIgnore
*/
set HttpClientToUse(client: HttpClient) {
if (this.Channel) {
(this.Channel as any).HttpClient = client;
}
}
protected get Channel(): T {
return this.#_channel;
}
protected set Channel(value: T) {
this.#_channel = value;
}
constructor();
constructor(configurationName: string);
constructor(configurationName: string, remoteAddress: string);
constructor(configurationName: string, remoteAddress: EndpointAddress);
constructor(binding: CommunicationBinding, remoteAddress: EndpointAddress);
constructor(p1?: any, p2?: any) {
if (typeof p1 === 'undefined' && typeof p2 === 'undefined') {
this.serviceName = this.constructor.name.replace(/Client$/, '.svc');
this.url = window.location.origin.toString() + '/';
this.url = `${this.url}${this.serviceName}`;
} else if (typeof p2 === 'string') {
this.url = p2;
} else if (p2 instanceof EndpointAddress) {
this.url = p2.address;
}
if (p1 instanceof CommunicationBinding) {
this.binding = p1;
}
if (!this.binding) {
this.binding = new WcfCustomBinding();
}
if ((this as any).CreateChannel) {
this.Channel = (this as any).CreateChannel();
}
}
/**
* Gets default value for initialization
*
* @protected
* @template T
* @param {*} reifiedType
* @returns {T}
* @memberof ClientBase
* @wIgnore
*/
protected GetDefaultValueForInitialization<T>(reifiedType): T {
if (reifiedType === Number) {
return 0 as unknown as T;
} else if (reifiedType === Boolean) {
return false as unknown as T;
}
return null;
}
/**
* Invokes service method
*
* @param {(v1: any[], v2: AsyncCallback, v3: any) => IAsyncResult} beginOperationCallback
* @param {any[]} inputValue
* @param {(v1: IAsyncResult) => any[]} endOperationCallback
* @param {(v1: any) => void} operationCompletedCallback
* @param {*} userState
* @return {*} {*}
* @memberof ClientBase
*/
public InvokeAsync(
beginOperationCallback: (
v1: any[],
v2: AsyncCallback,
v3: any
) => IAsyncResult,
inputValue: any[],
endOperationCallback: (v1: IAsyncResult) => any[],
operationCompletedCallback: (v1: any) => void,
userState: any
): any {
const result = beginOperationCallback(
inputValue,
endOperationCallback,
userState
);
result.callback = operationCompletedCallback;
}
/**
* BeginOpen method.
*
* @param {AsyncCallback} callback
* @param {*} asyncState
* @return {*} {IAsyncResult}
* @memberof ClientBase
* @wIgnore
*/
BeginOpen(callback: AsyncCallback, asyncState: any): IAsyncResult {
Debugger.Throw('Method not implemented.');
return null;
}
/**
* EndOpen method
*
* @param {IAsyncResult} result
* @memberof ClientBase
* @wIgnore
*/
EndOpen(result: IAsyncResult) {
Debugger.Throw('Method not implemented.');
}
/**
* EndClose method
*
* @param {IAsyncResult} result
* @memberof ClientBase
* @wIgnore
*/
EndClose(result: IAsyncResult) {
Debugger.Throw('Method not implemented.');
}
/**
* BeginClose method
*
* @param {AsyncCallback} callback
* @param {*} asyncState
* @return {*} {IAsyncResult}
* @memberof ClientBase
* @wIgnore
*/
BeginClose(callback: AsyncCallback, asyncState: any): IAsyncResult {
Debugger.Throw('Method not implemented.');
return null;
}
/**
* Causes the ClientBase object to transition immediately from its current state into the closed state.
*
* @memberof ClientBase
* @wNoMap
*/
Abort(): void {
Debugger.Throw('Method not implemented.');
}
/**
* Open method
*
* @param {number} timeout
* @memberof ClientBase
* @wIgnore
*/
Open(timeout: number): void {
Debugger.Throw('Method not implemented.');
}
/**
* Close method
*
* @param {number} timeout
* @memberof ClientBase
* @wIgnore
*/
Close(timeout: number): void {
Debugger.Throw('Method not implemented.');
}
/**
* BeginCloseWithTimeout method
*
* @param {TimeRange} timeout
* @param {AsyncCallback} callback
* @param {*} asyncState
* @return {*} {IAsyncResult}
* @memberof ClientBase
* @wIgnore
*/
BeginCloseWithTimeout(
timeout: TimeRange,
callback: AsyncCallback,
asyncState: any
): IAsyncResult {
Debugger.Throw('Method not implemented.');
return null;
}
/**
* BeginOpenWithTimeout method
*
* @param {TimeRange} timeout
* @param {AsyncCallback} callback
* @param {*} asyncState
* @return {*} {IAsyncResult}
* @memberof ClientBase
* @wIgnore
*/
BeginOpenWithTimeout(
timeout: TimeRange,
callback: AsyncCallback,
asyncState: any
): IAsyncResult {
Debugger.Throw('Method not implemented.');
return null;
}
/**
* OpenWithTimeout method
*
* @param {TimeRange} timeout
* @memberof ClientBase
* @wIgnore
*/
OpenWithTimeout(timeout: TimeRange): void {
Debugger.Throw('Method not implemented.');
}
/**
* CloseWithTimeout method
*
* @param {TimeRange} timeout
* @memberof ClientBase
* @wIgnore
*/
CloseWithTimeout(timeout: TimeRange): void {
Debugger.Throw('Method not implemented.');
}
}