Back to Devexpress

IObjectSpace.CanInstantiate(Type) Method

expressappframework-devexpress-dot-expressapp-dot-iobjectspace-dot-caninstantiate-x28-system-dot-type-x29.md

latest3.2 KB
Original Source

IObjectSpace.CanInstantiate(Type) Method

Indicates whether instances of a particular type can be created.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
bool CanInstantiate(
    Type type
)
vb
Function CanInstantiate(
    type As Type
) As Boolean

Parameters

NameTypeDescription
typeType

An object type for which it must be determined whether its instances can be created.

|

Returns

TypeDescription
Boolean

true , if instances of the specified type can be created; otherwise, false.

|

Remarks

To determine whether a particular type can be instantiated, use the IEntityStore (Type Info Source) object that must be passed as a parameter in the Object Space’s constructor. To be instantiated, the requested type must be contained in the IEntityStore.RegisteredEntities collection.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CanInstantiate(Type) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

XAF_how-to-connect-different-data-models-to-several-databases-within-a-single-application/CS/EFCore/ClassLibrary1/XafModule1.cs#L53

csharp
// Check whether it is a valid ObjectSpace to create objects of a certain type.
if (ObjectSpace.CanInstantiate(typeof(PersistentClass1))) {
    string str = "test1";

XAF_Non-Persistent-Objects-Nested-In-Persistent-Objects-Demo/CS/XPO/NonPersistentDemo/NonPersistentDemo.Module/DatabaseUpdate/DemoData.cs#L16

csharp
public void CreateDemoObjects() {
    if(ObjectSpace.CanInstantiate(typeof(Project))) {
        if(!ObjectSpace.CanInstantiate(typeof(Technology))) {

See Also

IObjectSpace Interface

IObjectSpace Members

DevExpress.ExpressApp Namespace