All docs
V21.2
21.2
21.1
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET 5.0+

CompositeObjectSpace.AdditionalObjectSpaces Property

Gets the list of Object Spaces used to handle objects that do not belong to the current Object Space. We recommend that you call the PopulateAdditionalObjectSpaces(XafApplication) method to populate this collection automatically.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v21.2.dll

Declaration

public IList<IObjectSpace> AdditionalObjectSpaces { get; }

Property Value

Type Description
IList<IObjectSpace>

An IList<T> collection of Object Spaces used to handle objects that do not belong to the current Object Space.

Exceptions

Type Description
InvalidOperationException

Cannot add the Object Space to the CompositeObjectSpace.AdditionalObjectSpaces collection because another Object Space for the same object types already exists.

Remarks

You can use one of the following ways to fill this collection.

  1. Handle the XafApplication.ObjectSpaceCreated event in a module or Controller.
  2. In the event handler, call the PopulateAdditionalObjectSpaces(XafApplication) method to populate the AdditionalObjectSpaces collection with all necessary Object Spaces.

The following example demonstrates how to do this in a platform-agnostic module (MySolution.Module/Module.cs(vb)):

using DevExpress.ExpressApp;
//...
public class MySolutionModule : ModuleBase {
    //...
    public override void Setup(XafApplication application) {
        base.Setup(application);
        application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
    }
    private void Application_ObjectSpaceCreated(object sender, ObjectSpaceCreatedEventArgs e) {
        CompositeObjectSpace compositeObjectSpace = e.ObjectSpace as CompositeObjectSpace;
        if (compositeObjectSpace != null) {
            if (!(compositeObjectSpace.Owner is CompositeObjectSpace)) {
                compositeObjectSpace.PopulateAdditionalObjectSpaces((XafApplication)sender);
            }
        }
    }
}

Manually: Create Object Spaces and Add Them to the Collection

If you need to create an additional Object Space manually, follow the steps below:

  1. Handle the XafApplication.ObjectSpaceCreated event in a module or Controller.
  2. In the event handler, access NonPersistentObjectSpace and use its IsKnownType(Type, Boolean) method to ensure that the AdditionalObjectSpaces collection does not already include a compatible Object Space.

The following example demonstrates how to do this in a platform-agnostic module (MySolution.Module/Module.cs(vb)):

using DevExpress.ExpressApp;
//...
public class MySolutionModule : ModuleBase {
    //...
    public override void Setup(XafApplication application) {
        base.Setup(application);
        application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
    }
    private void Application_ObjectSpaceCreated(object s, ObjectSpaceCreatedEventArgs e) {
        var nonPersistentObjectSpace = e.ObjectSpace as NonPersistentObjectSpace;
        if (nonPersistentObjectSpace != null) {
            if (!nonPersistentObjectSpace.IsKnownType(typeof(Person), true)) {
                IObjectSpace additionalObjectSpace = Application.CreateObjectSpace(typeof(Person));
                // customize the created additional Object Space
                nonPersistentObjectSpace.AdditionalObjectSpaces.Add(additionalObjectSpace);
                nonPersistentObjectSpace.Disposed += (s2, e2) => {
                    additionalObjectSpace.Dispose();
                };
            }
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AdditionalObjectSpaces property.

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.

See Also