Back to Devexpress

CompositeObjectSpace.PopulateAdditionalObjectSpaces(XafApplication) Method

expressappframework-devexpress-dot-expressapp-dot-compositeobjectspace-dot-populateadditionalobjectspaces-x28-devexpress-dot-expressapp-dot-xafapplication-x29.md

latest6.6 KB
Original Source

CompositeObjectSpace.PopulateAdditionalObjectSpaces(XafApplication) Method

Creates Object Spaces for registered Object Space Providers and adds them to the AdditionalObjectSpaces collection. Object Spaces in this collection are automatically disposed of with the owner Object Space.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public void PopulateAdditionalObjectSpaces(
    XafApplication application
)
vb
Public Sub PopulateAdditionalObjectSpaces(
    application As XafApplication
)

Parameters

NameTypeDescription
applicationXafApplication

An XAF application instance where Object Space Providers are registered.

|

Remarks

Follow the steps below to use this method:

  1. Handle the OnObjectSpaceCreated event in the Application Builder code in the application’s Startup.cs file.
  2. In the event handler, call the PopulateAdditionalObjectSpaces(IObjectSpaceProviderService, IObjectSpaceCustomizerService) method to populate the AdditionalObjectSpaces collection with all necessary Object Spaces.

File: MySolution.Blazor.Server/Startup.cs, MySolution.Win/Startup.cs, MySolution.WebApi/Startup.cs

csharp
using DevExpress.ExpressApp;
//...
builder.ObjectSpaceProviders.Events.OnObjectSpaceCreated = context => {
    CompositeObjectSpace compositeObjectSpace = context.ObjectSpace as CompositeObjectSpace;
    if (compositeObjectSpace != null) {
        if (!(compositeObjectSpace.Owner is CompositeObjectSpace)) {
            var objectSpaceProviderService = context.ServiceProvider.GetRequiredService<IObjectSpaceProviderService>();
            var objectSpaceCustomizerService = context.ServiceProvider.GetRequiredService<IObjectSpaceCustomizerService>();
            compositeObjectSpace.PopulateAdditionalObjectSpaces(objectSpaceProviderService, objectSpaceCustomizerService);
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the PopulateAdditionalObjectSpaces(XafApplication) 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-show-persistent-objects-in-a-non-persistent-objects-view/CS/EFCore/ComplexDialogEF/ComplexDialogEF.Module/Module.cs#L36

csharp
if (!(compositeObjectSpace.Owner is CompositeObjectSpace)) {
    compositeObjectSpace.PopulateAdditionalObjectSpaces((XafApplication)sender);
}

XAF_Non-Persistent-Objects-Reloading-Demo/CS/EFCore/NonPersReloadEF/NonPersReloadEF.Module/Module.cs#L42

csharp
if(!(npos.Owner is CompositeObjectSpace)) {
    npos.PopulateAdditionalObjectSpaces((XafApplication)sender);
}

XAF_Non-Persistent-Objects-Edit-Linked-Persistent-Objects-Demo/CS/EFCore/NonPersistentEditEF/NonPersistentEditEF.Module/Module.cs#L42

csharp
if(!(npos.Owner is CompositeObjectSpace)) {
    npos.PopulateAdditionalObjectSpaces((XafApplication)sender);
}

XAF_Non-Persistent-Objects-Nested-In-Persistent-Objects-Demo/CS/XPO/NonPersistentDemo/NonPersistentDemo.Module/Module.cs#L44

csharp
if(!(cos.Owner is CompositeObjectSpace)) {
    cos.PopulateAdditionalObjectSpaces((XafApplication)sender);
    cos.AutoCommitAdditionalObjectSpaces = true;

xaf-custom-logon-parameters/CS/XPO/WinForms/CustomLogonXPOWin/CustomLogonXPOWin.Win/WinApplication.cs#L31

csharp
if(nonPersistentObjectSpace != null) {
    nonPersistentObjectSpace.PopulateAdditionalObjectSpaces(application);
}

XAF_how-to-connect-different-data-models-to-several-databases-within-a-single-application/VB/CommonModule/CommonModule.vb#L40

vb
Private Sub Application_ObjectSpaceCreated(ByVal sender As Object, ByVal e As ObjectSpaceCreatedEventArgs)
    TryCast(e.ObjectSpace, CompositeObjectSpace)?.PopulateAdditionalObjectSpaces(CType(sender, XafApplication))
End Sub

See Also

CompositeObjectSpace Class

CompositeObjectSpace Members

DevExpress.ExpressApp Namespace