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




This interface is implemented if a persistent wants to create persistent types depending on the content of the current data record.

Syntax

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

Example

The following sample shows the usage of this interface.
C#Copy Code
            [Persistent("USERS")] 
public class User : IPersistentTypeSelector 

    // ... Properties and fields of the persistent. 
 
    private Type FetchPersistentType(IDataRecord dataRecord) 
    { 
        if (e.DataRecord["Type"] == "1") 
        { 
            // Switch the type of the persistent that is created to User1. 
            return typeof(User1); 
        } 
        else if ((bool)e.DataRecord["Ignore"]) 
        { 
            // Tell the framework to ignore this item. 
            return null; 
        } 
        // Have a persistent of type User created. 
        return typeof(User); 
    } 

 
// This class inherits from User. 
public class User1 : User 

    // ... Properties and fields of the object. 
}

Remarks

Classes that create persistent types depending on the content of the current data record should implement this interface. It allows to return a type that is created instead of the class that is implementing this interface. Usually that is a class that inherits of the persistent that implements this interface.

If null is returned the current record is ignored (no persistent object instance is created from the current record).

Requirements

Namespace: Chili.Opf3

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