File

projects/wms-framework/src/lib/wcfserviceinvocationsupport/channels.ts

Description

The collection of binding elements used in a binding.

Extends

SimpleList

Index

Properties
Methods

Properties

Protected _internalArray
Type : T[]
Default value : []
Inherited from SimpleList
Defined in SimpleList:276
Protected Static interfacesInitialized
Default value : false
Inherited from SimpleList
Defined in SimpleList:274

Methods

add
add(value: T)
Inherited from SimpleList
Defined in SimpleList:389

Adds an element to the list

Parameters :
Name Type Optional
value T No
Returns : void
addRange
addRange(range: Iterable<T>)
Inherited from SimpleList
Defined in SimpleList:452

Adds elements of an iterable to the list

Parameters :
Name Type Optional
range Iterable<T> No
Returns : void
clear
clear()
Inherited from SimpleList
Defined in SimpleList:398

Clears the list

Returns : void
contains
contains(value: T)
Inherited from SimpleList
Defined in SimpleList:410

Check if a value is contained in the list

Parameters :
Name Type Optional
value T No
Returns : boolean
copyTo
copyTo(target: T[], index: number)
Inherited from SimpleList
Defined in SimpleList:513

Copies the list to a target array

Parameters :
Name Type Optional
target T[] No
index number No
Returns : void
forEach
forEach(action: (e: T) => void)
Inherited from SimpleList
Defined in SimpleList:439

Performs an action on each element of the list

Parameters :
Name Type Optional
action function No
Returns : void
getItem
getItem(index: number)
Inherited from SimpleList
Defined in SimpleList:323
Parameters :
Name Type Optional
index number No
Returns : T
indexOf
indexOf(value: T)
Inherited from SimpleList
Defined in SimpleList:343

Index of value in list

Parameters :
Name Type Optional
value T No
Returns : any
Protected Static initializeSupportedInterfaces
initializeSupportedInterfaces()
Inherited from SimpleList
Defined in SimpleList:278
Returns : void
insert
insert(index: number, value: T)
Inherited from SimpleList
Defined in SimpleList:355

Inserts element in index

Parameters :
Name Type Optional
index number No
value T No
Returns : void
insertRange
insertRange(position: number, range: Iterable<T>)
Inherited from SimpleList
Defined in SimpleList:466

Inserts elements of an interable to the list in a position

Parameters :
Name Type Optional
position number No
range Iterable<T> No
Returns : void
remove
remove(value: T)
Inherited from SimpleList
Defined in SimpleList:422

Removes a value from the list

Parameters :
Name Type Optional
value T No
Returns : boolean
Public removeAll
removeAll(predicate: (e: T) => void)
Inherited from SimpleList
Defined in SimpleList:527

Removes all elements from the collection by a predicate

Parameters :
Name Type Optional
predicate function No
Returns : number
removeAt
removeAt(index: number)
Inherited from SimpleList
Defined in SimpleList:366

Removes element at index

Parameters :
Name Type Optional
index number No
Returns : void
setItem
setItem(index: number, value: T)
Inherited from SimpleList
Defined in SimpleList:329
Parameters :
Name Type Optional
index number No
value T No
Returns : void
sort
sort()
Inherited from SimpleList
Defined in SimpleList:479

Sorts the list

Returns : any
Public toArray
toArray()
Inherited from SimpleList
Defined in SimpleList:545

Converts the list to an array

Returns : {}
()
Inherited from SimpleList
Defined in SimpleList:549
Returns : Iterator<T, any, undefined>
import { Uri } from '../baseframework/Uri';
import {
  ICommunicationObject,
  CommunicationBinding,
} from './CommunicationSupport';
import { SimpleList } from '../baseframework/collections';
import { EndpointAddress } from './EndpointAddress';
import { WcfBindingElement } from './WcfBindingElement';
import { WcfBindingContext } from './WcfBindingContext';
import { WcfChannelFactoryBase } from './WcfChannelFactoryBase';
import { WcfMessage } from './WcfMessage';
import {
  ClassType,
  tryExplicitDeserialization,
  tryImplicitDeserialization,
} from '../baseframework';
import { Message } from './Message';

/**
 * Interface that must be implemented by channel factories that create type-specific channels.
 *
 * @export
 * @interface IChannelFactory
 * @extends {ICommunicationObject}
 * @template T The type of channel that the channel factory creates.
 * @wInterface System.ServiceModel.Channels.IChannelFactory`1
 */
export interface IChannelFactory<T> extends ICommunicationObject {
  CreateChannel(to: EndpointAddress, via: Uri): any;

  /**
   * OnCreateChannel method
   *
   * @param {EndpointAddress} to
   * @param {Uri} via
   * @return {*}  {*}
   * @memberof IChannelFactory
   * @wIgnore
   */
  OnCreateChannel(to: EndpointAddress, via: Uri): any;

  /**
   * Gets the property
   *
   * @template T
   * @param {ClassType} TParam
   * @return {*}  {T}
   * @memberof IChannelFactory
   * @wIgnore
   */
  GetProperty<T>(TParam: ClassType): T;
}

/**
 * Represents the binding element used to specify an HTTP transport for transmitting messages.
 *
 * @export
 * @class HttpTransportBindingElement
 * @extends {WcfBindingElement}
 * @wType System.ServiceModel.Channels.HttpTransportBindingElement
 */
export class HttpTransportBindingElement extends WcfBindingElement {
  /**
   * Creates a channel factory that can be used to create a channel.
   *
   * @template TChannel
   * @param {Function} TChannelParam
   * @param {WcfBindingContext} context
   * @return {*}  {WcfChannelFactoryBase<TChannel>}
   * @memberof HttpTransportBindingElement
   * @wNoMap
   */
  public BuildChannelFactory<TChannel>(
    TChannelParam: Function,
    context: WcfBindingContext
  ): WcfChannelFactoryBase<TChannel> {
    return null;
  }
  public MaxBufferSize: number = 0;

  /**
   * MaxReceivedMessageSize property
   *
   * @type {number}
   * @memberof HttpTransportBindingElement
   * @wIgnore
   */
  public MaxReceivedMessageSize: number = 0;
}

/**
 * Represents the binding element used to specify an HTTPS transport for transmitting messages.
 *
 * @export
 * @class HttpsTransportBindingElement
 * @extends {HttpTransportBindingElement}
 * @wType System.ServiceModel.Channels.HttpsTransportBindingElement
 */
export class HttpsTransportBindingElement extends HttpTransportBindingElement {}

/**
 * The binding element that specifies the .NET Binary Format for XML used to encode messages.
 *
 * @export
 * @class BinaryMessageEncodingBindingElement
 * @extends {WcfBindingElement}
 * @wType System.ServiceModel.Channels.BinaryMessageEncodingBindingElement
 */
export class BinaryMessageEncodingBindingElement extends WcfBindingElement {
  /**
   * Builds the channel factory stack on the client that creates a specified type of channel for a specified context.
   *
   * @template TChannel
   * @param {Function} TChannelParam
   * @param {WcfBindingContext} context
   * @return {*}  {WcfChannelFactoryBase<TChannel>}
   * @memberof BinaryMessageEncodingBindingElement
   * @wNoMap
   */
  public BuildChannelFactory<TChannel>(
    TChannelParam: Function,
    context: WcfBindingContext
  ): WcfChannelFactoryBase<TChannel> {
    return null;
  }
}

/**
 * The collection of binding elements used in a binding.
 *
 * @export
 * @class BindingElementCollection
 * @extends {SimpleList<WcfBindingElement>}
 * @wType System.ServiceModel.Channels.BindingElementCollection
 */
export class BindingElementCollection extends SimpleList<WcfBindingElement> {}

/**
 * Defines a binding from a list of binding elements.
 *
 * @export
 * @class WcfCustomBinding
 * @extends {CommunicationBinding}
 * @wType System.ServiceModel.Channels.CustomBinding
 */
export class WcfCustomBinding extends CommunicationBinding {
  Elements: BindingElementCollection = new BindingElementCollection();

  constructor() {
    super();
    this.UsePost = true;
  }

  CreateBindingElements(): any {
    return this.Elements;
  }

  /**
   * CreateMessage method
   *
   * @param {string} baseUrl
   * @param {string} methodName
   * @param {any[]} args
   * @return {*}  {Message}
   * @memberof WcfCustomBinding
   * @wIgnore
   */
  CreateMessage(baseUrl: string, methodName: string, args: any[]): Message {
    let message = new WcfMessage();
    /* istanbul ignore next */
    if (this.EndpointSuffix) {
      message.EndpointSuffix = this.EndpointSuffix;
    }
    message.BaseUrl = baseUrl;
    message.UsePost = this.UsePost;
    message.methodName = methodName;
    message.requestArgs = args;
    message.Headers.clear(); //Cleaning previous headers sent before
    return message;
  }

  /**
   * CreateResponseMessage method
   *
   * @param {*} result
   * @param {*} [classConstructor]
   * @return {*}  {Message}
   * @memberof WcfCustomBinding
   * @wIgnore
   */
  CreateResponseMessage(result: any, classConstructor?: any): Message {
    let resultToTransfer = null;
    if (
      result?.AsyncState?.d ||
      result?.AsyncState?.d === '' ||
      result?.AsyncState?.d === 0
    ) {
      resultToTransfer = tryImplicitDeserialization(
        result.AsyncState.d,
        classConstructor
      );
      if (typeof classConstructor !== 'undefined') {
        let convertedToType = resultToTransfer instanceof classConstructor;
        if (!convertedToType) {
          if (resultToTransfer instanceof Array) {
            return new classConstructor(resultToTransfer);
          } else {
            return tryExplicitDeserialization(
              resultToTransfer,
              classConstructor
            );
          }
        }
      }
    }

    let resultMessage = new WcfMessage();
    resultMessage.result = resultToTransfer;
    return resultMessage;
  }
}

result-matching ""

    No results matching ""