Skip to content

Commit 871c4f9

Browse files
committed
Review interact doc
1 parent 7113071 commit 871c4f9

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/csharp/extensibility-api-howtos/interact-with-model-api.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,31 @@ weight: 11
77

88
## Introduction
99

10-
After you create some basic extensions, you want to interact with the Studio Pro model in order to make changes to your app. The Model API allows you to do just that. The model representation is exposed via the `Mendix.StudioPro.ExtensionsAPI.Model` namespace.
10+
Once you have created basic extensions, you may want to interact with the Studio Pro model to make changes to your app. The Model API enables this functionality and is exposed via the `Mendix.StudioPro.ExtensionsAPI.Model` namespace.
1111

1212
## Gaining Access to the Mendix Model SDK
1313

14-
The easiest way to gain access to the model is by using the `CurrentApp` property of Extension class. All extension classes implement the [`Mendix.StudioPro.ExtensionsAPI.UI.UIExtensionBase`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI/UIExtensionBase.md) base class which provides this access.
14+
To access the model, use the `CurrentApp` property of your extension class. All extension classes implement the [`Mendix.StudioPro.ExtensionsAPI.UI.UIExtensionBase`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.UI/UIExtensionBase.md) base class, which provides access to `CurrentApp`.
1515

16-
The `CurrentApp` property exposes an implementation of [`IModel`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/IModel.md). With a `IModel` reference you can gain access to any other model elements. However, any changes that you introduce must be contained within a model transaction.
16+
The `CurrentApp` property exposes an implementation of [`IModel`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/IModel.md). This gives you access to all model elements.
17+
18+
{{% alert type="info" %}}
19+
Any changes made to the model must be contained within a model transaction.
20+
{{% /alert %}}
1721

1822
## Interacting with Model Elements
1923

20-
Any modification to the model must be done within a transaction; otherwise, a `System.InvalidOperationException` is thrown. There can be only a single active (i.e. not committed or rolled back) `ITransaction` for the whole app.
24+
Any modification to the model must be done within a transaction; otherwise, a `System.InvalidOperationException` is thrown. There can be only a single active (for example, not committed or rolled back) `ITransaction` for the whole app.
25+
26+
Transactions group changes, but do not provide a way to isolate them. Changes to a model are immediately visible to all code interacting with the model. When transaction is rolled back or is undone by a user, all included changes are reverted.
2127

22-
Transactions do not provide a way to isolate changes, but to group them. That is, any change to a model is immediately visible to all code working with the model. When transaction is rolled back programmatically or is undone by a user, all changes included in it are reverted.
28+
## Start a Transaction
2329

24-
To create transaction you can call [`IModel.StartTransaction`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/IModel/StartTransaction.md). This method will return a transaction object which implements [`ITransaction`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/ITransaction.md).
30+
To create transaction, call [`IModel.StartTransaction`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/IModel/StartTransaction.md). This method returns a transaction object that implements [`ITransaction`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/ITransaction.md).
2531

2632
For your changes to reflect within the model, you must first commit the transaction by calling [`ITransaction.Commit`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/ITransaction/Commit.md).
2733

28-
Alternatively, if you wish to abort or revert your changes, you can call [`ITransaction.Rollback`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/ITransaction/Rollback.md).
34+
If you wish to abort or revert your changes, call [`ITransaction.Rollback`](https://github.com/mendix/ExtensionAPI-Samples/blob/main/API%20Reference/Mendix.StudioPro.ExtensionsAPI.Model/ITransaction/Rollback.md).
2935

3036
## Examples
3137

@@ -41,7 +47,7 @@ using (var transaction = model.StartTransaction("rename folder"))
4147
}
4248
```
4349

44-
Here is another simple example. It adds an entity named `testEntity` and adds an attribute called `testAttribute` to it.
50+
The next example below adds an entity named `testEntity` and adds an attribute called `testAttribute` to it.
4551

4652
```csharp
4753
using (var transaction = model.StartTransaction("add entity"))

0 commit comments

Comments
 (0)