| IGLib 1.7.2 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Attributes | List of all members
IG.Lib.SerializationDtoBase< Type, BaseType > Class Template Referenceabstract

Generic base class for Data Transfer Objects (DTO). This class is used as template for producing concrete DTO classes. Such DTOs are used for serialization and deserialization of state of various kinds of objects that need to be transfered between applications, across platforms, or simply stored in files for future use. WARNING: In most cases ISerializationDto type will be used. Different BaseType and Type are used only in relatively rare cases where different derived types all have the same data that is copied to DTO. Otherwise the advantage of this can not be used because of single inheritance. More...

Inheritance diagram for IG.Lib.SerializationDtoBase< Type, BaseType >:
[legend]
Collaboration diagram for IG.Lib.SerializationDtoBase< Type, BaseType >:
[legend]

## Public Member Functions
| SerializationDtoBase ()
virtual bool | GetNull ()
| Returns a flag indicating whether the object represented by the current DTO is null. More...
virtual void | SetNull (bool isNull)
| Sets a flag indicating whether the object represented by the current DTO is null. More...
abstract Type | CreateObject ()
| Creates and returns a new object of the type whose data is represented by the current DTO (Data Transfer Object). WARNING: Implement thread locking in overriding functions! More...
virtual void | CopyFromBase (BaseType obj)
| Copies data to the current DTO from an object of type BaseType. More...
virtual void | CopyToBase (ref BaseType obj)
| Copies data from the current DTO to an object of the base type. Object is created anew if necessary by using the CreateObject() method. More...
virtual void | CopyFrom (Type obj)
| Copies data to the current DTO from an object of type Type. More...
virtual void | CopyTo (ref Type obj)
| Copies data from the current DTO to an object of type Type. Object is created anew if necessary by using the CreateObject() method. More...
virtual void | CopyFromObject (object obj)
| Copies data to the current DTO from an object of type object. The necessary casts are performed. More...
virtual void | CopyToObject (ref object obj)
| Copies data from the current DTO to an object of type object. Object is created anew if necessary by using the CreateObject() method. The necessary casts are performed. More...
override string | ToString ()
| Creates and returns string representation of the current DTO (data transfer object). More...

## Protected Member Functions
abstract void | CopyFromPlain (BaseType obj)
| Copies contents of the specified object to the current DTO (Data Transfer Object). More...
abstract void | CopyToPlain (ref BaseType obj)
| Copies contents of the current DTO (Data Transfer Object) to the specified object. More...
Protected Member Functions inherited from IG.Lib.SerializationDto
| SerializationDto ()

## Protected Attributes
bool | _isNull = false

## Properties
object | Lock`[get]`
| This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. More...
Properties inherited from IG.Lib.ILockable
object | Lock`[get]`

## Private Attributes
object | _mainLock = new object()

## Additional Inherited Members
Static Public Member Functions inherited from IG.Lib.SerializationDto
static ObjectType | CopyToObjectReturned< DtoType, ObjectType > (DtoType dto, ObjectType obj)
| Replacement for CopyToObject for cases where object can not be passed by reference. The returned object must be assigned to object (property, list element, etc.) to which object state is copied. More...
static void | CopyToObject< DtoType, ObjectType > (DtoType dto, ref ObjectType obj)
| Copies object state form the specified DTO (data transfer object) to the specified object. More...
static DtoType | CopyFromObjectReturned< DtoType, ObjectType > (ObjectType obj, DtoType dto)
| Replacement for CopyFromObject for cases where object can not be passed by reference. The returned object must be assigned to object (property, list element, etc.) to which object state is copied. More...
static void | CopyFromObject< DtoType, ObjectType > (ObjectType obj, ref DtoType dto)
| Copies object state form the specified object to the corresponding DTO (data transfer object). More...
static ObjectType[] | CopyArrayToObjectReturned< DtoType, ObjectType > (DtoType[] tabDto, ObjectType[] tabObj)
| Replacement for CopyArrayToObject for cases where object can not be passed by reference. The returned object must be assigned to object (property, list element, etc.) to which data is copied. More...
static void | CopyArrayToObject< DtoType, ObjectType > (DtoType[] tabDto, ref ObjectType[] tabObj)
| Copies array of DTOs (Data Transfer Objects) to an array of appropriate objects. More...
static DtoType[] | CopyArrayFromObjectReturned< DtoType, ObjectType > (ObjectType[] tabObj, DtoType[] tabDto)
| Replacement for CopyArrayFromObject for cases where object can not be passed by reference. The returned object must be assigned to object (property, list element, etc.) to which data is copied. More...
static void | CopyArrayFromObject< DtoType, ObjectType > (ObjectType[] tabObj, ref DtoType[] tabDto)
| Copies array of objects to an array of DTOs. More...
static List< ObjectType > | CopyListToObjectReturned< DtoType, ObjectType > (DtoType[] tabDto, List< ObjectType > listObj)
| Replacement for CopyListToObject for cases where object can not be passed by reference. The returned object must be assigned to object (property, list element, etc.) to which data is copied. More...
static void | CopyListToObject< DtoType, ObjectType > (DtoType[] tabDto, ref List< ObjectType > listObj)
| Copies array of DTOs (Data Transfer Objects) to a list of appropriate objects. More...
static DtoType[] | CopyListFromObjectReturned< DtoType, ObjectType > (List< ObjectType > tabObj, DtoType[] tabDto)
| Replacement for CopyArrayFromObject for cases where object can not be passed by reference. The returned object must be assigned to object (property, list element, etc.) to which data is copied. More...
static void | CopyListFromObject< DtoType, ObjectType > (List< ObjectType > tabObj, ref DtoType[] tabDto)
| Copies array of objects to a list of DTOs. More...

## Detailed Description

Generic base class for Data Transfer Objects (DTO). This class is used as template for producing concrete DTO classes. Such DTOs are used for serialization and deserialization of state of various kinds of objects that need to be transfered between applications, across platforms, or simply stored in files for future use. WARNING: In most cases ISerializationDto type will be used. Different BaseType and Type are used only in relatively rare cases where different derived types all have the same data that is copied to DTO. Otherwise the advantage of this can not be used because of single inheritance.

Template Parameters

  Type | Type for which DTO is used.
  BaseType | Base type of the type for which DTO is used, and on which copy operations will be defined. In this way, we can avoid defining these operations for each specific type, but only define them for a specific type, since operations may be similar for all derived types.

There is an agreement that all derived classes must have a public argument-less (default) constructor. Generic classes are usually not used for serialization/deserialization. Only derived types where both type parameters are fixed are normally used for this purpos. IMPORTANT: Base type is used just for being able to define copying operations only once - for the base type - and using it for different derived types. In many occasions this will not be needed, and in these occasions one should just use the derived type that does not have base type as type parameter.

$A Igor Jun09;

Type Constraints

  BaseType | : | class |
  Type | : | class |
  Type | : | BaseType |

## Constructor & Destructor Documentation

IG.Lib.SerializationDtoBase< Type, BaseType >.SerializationDtoBase | ( |  | ) |
| inline

## Member Function Documentation

virtual bool IG.Lib.SerializationDtoBase< Type, BaseType >.GetNull | ( |  | ) |
| inline virtual

Returns a flag indicating whether the object represented by the current DTO is null.

Returns
  Flag indicating whether the object represented by the current DTO is null.

Implementing this as a function rather than a property prevents serialization of the flag, since the flag isn't meant to contain data, but to instruct operations that the object represented by the current DTO is null. This is useful in some scenarios where non-null DTOs are needed for null objects.

Implements IG.Lib.ISerializationDtoAux< Type >.

virtual void IG.Lib.SerializationDtoBase< Type, BaseType >.SetNull | ( | bool | isNull | ) |
| inline virtual

Sets a flag indicating whether the object represented by the current DTO is null.

Parameters

  isNull | If true, this flag indicates that the object represented by the current DTO is null, although the DTO itself is not null.

Implementing this as a function rather than a property prevents serialization of the flag, since the flag isn't meant to contain data, but to instruct operations that the object represented by the current DTO is null. This is useful in some scenarios where non-null DTOs are needed for null objects.

Implements IG.Lib.ISerializationDtoAux< Type >.

abstract Type IG.Lib.SerializationDtoBase< Type, BaseType >.CreateObject | ( |  | ) |
| pure virtual

Creates and returns a new object of the type whose data is represented by the current DTO (Data Transfer Object). WARNING: Implement thread locking in overriding functions!

Therad locking should be performed in overriding functions!

Implements IG.Lib.ISerializationDtoAux< Type >.

Implemented in IG.Lib.ListDto< ElementType, ElementBaseType, ElementDtoType >, IG.Lib.MatrixDtoBase< MatrixType >, IG.Lib.VectorDtoBase< VectorType >, IG.Lib.BoundingBoxDtoBase< BoxType >, IG.Lib.ArrayDto< ElementType, ElementBaseType, ElementDtoType >, and IG.Lib.IndexListDto.

abstract void IG.Lib.SerializationDtoBase< Type, BaseType >.CopyFromPlain | ( | BaseType | obj | ) |
| protected pure virtual

Copies contents of the specified object to the current DTO (Data Transfer Object).

Parameters

  obj | Object whose data is copied.

If the specified object is null then the _isNull property of the current DTO is set to true. Therad locking is usually not needed in overriding functions because it is normally implemeted in calling functions.

abstract void IG.Lib.SerializationDtoBase< Type, BaseType >.CopyToPlain | ( | ref BaseType | obj | ) |
| protected pure virtual

Copies contents of the current DTO (Data Transfer Object) to the specified object.

Parameters

  obj | Object that data is copied to.

If _isNull property of the current DTO is set to true then the object becomes null. Therad locking is usually not needed in overriding functions because it is normally implemeted in calling functions.

virtual void IG.Lib.SerializationDtoBase< Type, BaseType >.CopyFromBase | ( | BaseType | obj | ) |
| inline virtual

Copies data to the current DTO from an object of type BaseType.

Parameters

  obj | Object whose data is copied to the current DTO.

Implements IG.Lib.ISerializationDto< Type, BaseType >.

virtual void IG.Lib.SerializationDtoBase< Type, BaseType >.CopyToBase | ( | ref BaseType | obj | ) |
| inline virtual

Copies data from the current DTO to an object of the base type. Object is created anew if necessary by using the CreateObject() method.

Parameters

  obj | Object to which data is copied.

Implements IG.Lib.ISerializationDto< Type, BaseType >.

virtual void IG.Lib.SerializationDtoBase< Type, BaseType >.CopyFrom | ( | Type | obj | ) |
| inline virtual

Copies data to the current DTO from an object of type Type.

Parameters

  obj | Object whose data is copied to the current DTO.

Implements IG.Lib.ISerializationDtoAux< Type >.

virtual void IG.Lib.SerializationDtoBase< Type, BaseType >.CopyTo | ( | ref Type | obj | ) |
| inline virtual

Copies data from the current DTO to an object of type Type. Object is created anew if necessary by using the CreateObject() method.

Parameters

  obj | Object to which data is copied.

Implements IG.Lib.ISerializationDtoAux< Type >.

virtual void IG.Lib.SerializationDtoBase< Type, BaseType >.CopyFromObject | ( | object | obj | ) |
| inline virtual

Copies data to the current DTO from an object of type object. The necessary casts are performed.

Parameters

  obj | Object whose data is copied to the current DTO.

Implements IG.Lib.ISerializationDto< Type, BaseType >.

virtual void IG.Lib.SerializationDtoBase< Type, BaseType >.CopyToObject | ( | ref object | obj | ) |
| inline virtual

Copies data from the current DTO to an object of type object. Object is created anew if necessary by using the CreateObject() method. The necessary casts are performed.

Parameters

  obj | Object to which data is copied.

Implements IG.Lib.ISerializationDto< Type, BaseType >.

override string IG.Lib.SerializationDtoBase< Type, BaseType >.ToString | ( |  | ) |
| inline

Creates and returns string representation of the current DTO (data transfer object).

This is a generic method that first copies DTO to an object that it represents, and then calls the ToString() method of that object. This solution is slow, but this method usually does not need to be faster because ToString() method is usually only used for tests of this kind of classes.

## Member Data Documentation

bool IG.Lib.SerializationDtoBase< Type, BaseType >._isNull = false
| protected

object IG.Lib.SerializationDtoBase< Type, BaseType >._mainLock = new object()
| private

## Property Documentation

object IG.Lib.SerializationDtoBase< Type, BaseType >.Lock
| get

This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.

The documentation for this class was generated from the following file:

- igbase/data/serialization/SerializationDtoBase.cs