The ca.metaobjects.csogateway contains most of the public interface of the CSO Gateway: http handlers, code attribute classes, exceptions and the main object converters

Classes

  ClassDescription
CsoGatewayError
An unexpected exception in the CSO Gateway. Unexpected exceptions are those not caused by usual mistakes from the user.
CsoGatewayException
An expected exception in the CSO Gateway.
CsoGeneratedTypeAttribute

Specifies various parameters affecting the creation of the cso-generated type for the class, the struct, the interface or the enum that this attribute is attached to. Attaching this attribute to a class, a struct, an interface or an enum states that it is cso-ready, i.e that a cso-generated type can be created for it. Enums are automatically cso-ready so it is not necessary to decorate an enum definition with this attribute unless some parameters needs to be specified.

Parameter name Type Affects Effect
clientSideNamespace string class, struct, interface enum Will set the namespace of the cso-generated type. This overrides whatever is declared in the configuration.
extensionUrl string class, struct, interface The javascript file located at the specified URL will automatically be imported on the client whenever the cso-generated type is imported. This overrides whatever is declared in the configuration.
ignoreBaseClass bool? class The Type Morpher will completely ignore the base class of the current type. As if the type had System.Object as its base class.
CsoHashSourceAttribute

Specifies that the value returned by the equivalent property in the cso-generated type can be used to produce hash codes for instances of that cso-generated type. When a cso-ready class or a cso-ready struct has one or more of its public properties decorated with this attribute, the cso-generated type implements the interface CsoGateway.Collections.ICsoHashProvider and an additional function is created: getCsoHashSource(). That function will returns an Array of the values of the properties that were decorated with the CsoHashSourceAttribute on the server side. The values in that Array are used by the CsoGateway.Collections.Hashing.Hash(object) to produce hashes for objects that implements CsoGateway.Collections.ICsoHashProvider.

CsoPropertyExcludeAttribute

Specifies that the property this attribute is attached to should be ignored by the CSO Gateway.

This attribute can be attached to properties of classes and structs. The CSO Gateway ignores all non-public properties and all properties with no get accessor. In these cases the CsoPropertyExcludeAttribute has no effect. The case of properties in structs is pretty straightforward because there is no inheritance: the property will be completely ignored by the CSO Gateway. For classes, the effect of this attribute is inherited by the declarations of the same property in derived classes unless a derived class is decorated with the CsoGeneratedTypeAttribute (a cso-ready class) and has CsoGeneratedTypeAttribute.IgnoreBaseClass set to true. In that case, if that derived class or one of its derived classes declares the property again (by overriding or hiding it) the CSO Gateway will take it into account.

This attribute has different effects on a virtual/override inheritance chain of properties then on a non-virtual/new inheritance chain of property. When the attribute is attached to the base declaration of an inheritance chain of virtual/overrides properties (the one with the virtual modifier), all the other declarations in derived classes will also be ignored whether of not the class of the base declaration is cso-ready. When the attribute is attached to an overriding declaration of the property (the ones with the 'override' modifier), the attribute has -no effect-.

When the attribute is attached to the base declaration of an inheritance chain of non-virtual/new properties (a method with no inheritance modifier), all the other declarations in the derived classes will also be ignored whether of not the class of the base declaration is cso-ready and EVEN if a property hides its base declaration with the new modifier. When the attribute is attached to an hiding declaration of the property (with the 'new' modifier), that property will still be defined in the cso-generated type corresponding to the declaring class of the property. But the value retreived by the Object Gateway will be the value returned by the version of the property that is the closest up in the inheritance chain.

To sum up, the effect of the CsoPropertyExcludeAttribute on a property (disregarding the possibility of a CsoGeneratedTypeAttribute.IgnoreBaseClass set to true):
ModifierEffect
virtualThe property and all overriding declaration of that same property in derived classes are ignored. The property won't exist for any cso-type.
overrideNo effect.
-no inheritance modifier-The property and all the hiding declarations of that same property in derived classes are ignored. The property won't exist for any cso-type.
newThe property and all the hiding declarations of that same property in derived classes are ignored. But since the property is still declared in an ancestor class, the property will still be defined for the cso-generated type. The value retreived by the Object Gateway and passed to the constructor control will be from the declaration of the property that is closest up in the inheritance chain.

ImporterHttpHandler

Handles HTTP request made to the CSO Gateway to query the in-memory collection of cso-types.

The output of an HTTP request to this handler depends on the query string. This handler accepts only one key/value pair in the query string. The key is compared against a list of command names and the value is used to pass parameters to the command.

COMMAND FORMAT OF PARAMETERS CONTENT TYPE COMMENT
import ((#assembly-qualified name of type#)(#full name of cso-type#)) text/javascript Create cso-type is not created already. Return js code the cso-type.
view #full name of cso-type# text/html For debugging. Return js code of an existing cso-type.
reset all text/html Flushes all in-memory cso-types. Not thread-safe. For debugging only.

A request with the 'import' command will return a 'text/javascript' reponse containing the javascript code defining a cso-type. First, the handler will try to locate the cso-type with the given cso-type full name. If it is not found, it may be because it is a cso-generated type that has not been created and loaded in memory yet. Cso-generated types are created from types so an actual assembly-qualified name of a type is needed to created a cso-type. The given assembly-qualified name is passed to the System.Type.GetType(string) method. If a type is return and if the type is cso-ready, the cso-type is created by the Type Morpher and the javascript code defining it is written to the response.

A request with the 'view' command will return a text/html reponse containing the javascript code defining a cso-type. The cso-type must already be loaded in memory or an error message is returned. This is a debugging functionnaly that allows developper to see the source code of cso-type easily.

A request with the 'import' command and 'all' in as parameter will flush all loaded cso-type from the memory. This functionnality is not thread-safe and should only be used for debugging.

ToClientSideMainConverter

The ToClientSideMainConverter class is the main entry point for converting server-side objects into client-side values. More specifically, it provides the following functionnalities:

  • Recursively go through the composition graph of any cso-compatible object and generate a string of javascript code that, when evaluated, create an equivalent client-side value.
  • Provides the to-client-side conversion functionalities for types corresponding to cso-types (cso-generated types and cso-native types).
  • Provides the to-client-side conversion functionalities for .NET primitive types and many other commonly .NET types like System.DateTime and System.Array.

Here an exaustive list of the .NET types handled by this class

.NET primitive data types
TYPEJAVASCRIPT TYPECOMMENTS
System.BooleanBoolean-
System.ByteNumber-
System.SByteNumber-
System.Int16Number-
System.UInt16Number-
System.Int32Number-
System.UInt32Number-
System.Int64NumberRange limited. See ExceptionOnPrecisionLossInt64
System.UInt64NumberRange limited. See ExceptionOnPrecisionLossUInt64
System.CharString-
System.DoubleNumber-
System.SingleNumber-

Common data structure in .NET
TYPEJAVASCRIPT TYPECOMMENTS
System.StringString-
System.ArrayArrayN-dimensional arrays are supported. Contructor of Array core object is used.
System.DateTimeDateDate is a javacript predefined core object not a data type. Underlying data type is Number.
System.DecimalNumberRange limited. See ExceptionOnPrecisionLossDecimal

Special cases
TYPEJAVASCRIPT TYPECOMMENTS
#any null reference#NullNull is a javascript 'Special Type'