Chili.Opf3 Send comments on this topic.
ICustomDataTypesStorage Interface
See Also  Members   Example
Chili.Opf3.Storages Namespace : ICustomDataTypesStorage Interface




This interface is implemented by a storage that does not support all simple types of the .NET framework.

Syntax

Visual Basic (Declaration) 
Public Interface ICustomDataTypesStorage 
   Inherits IStorage 
Visual Basic (Usage)Copy Code
Dim instance As ICustomDataTypesStorage
C# 
public interface ICustomDataTypesStorage : IStorage  
Managed Extensions for C++ 
public __gc __interface ICustomDataTypesStorage : public IStorage  
C++/CLI 
public interface class ICustomDataTypesStorage : public IStorage  

Example

Firebird does, for example, not support the .NET type Boolean. Therefore a field with type integer is used in the database. By implementing this interface the integer from the database is converted to an boolean (during load of the object). When saving the object the boolean of the object is converted back to an integer.
C#Copy Code
object ICustomDataTypesStorage.ChangeFromDataType(object obj, Type targetType) 

    if (!(obj is bool) && targetType == typeof(bool)) 
        return Convert.ToBoolean(obj); 
    return obj; 

 
object ICustomDataTypesStorage.ChangeToDataType(object obj) 

    if (obj is bool) 
        return Convert.ToInt32((bool)obj); 
    return obj; 
}

Remarks

A storage that does not natively support all simple types of the .NET framework has to implement this interface. It allows the storage to change the type that comes from the storage to a type that is supported by the .NET framework and to change it back to a type that is supported by the storage.

Requirements

Namespace: Chili.Opf3.Storages

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Chili.Opf3 (in Chili.Opf3.dll)

See Also