Skip to content

Commit 27396bf

Browse files
committed
Updated articles
1 parent 97b9f90 commit 27396bf

File tree

3 files changed

+98
-39
lines changed

3 files changed

+98
-39
lines changed
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
---
2-
description: Configuring encrypted properties in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Configuring and using encrypted properties in Umbraco UI Builder to securely store sensitive data.
33
---
44

55
# Encrypted Properties
66

7-
If needed to collect sensitive information in a collection but don't want to persist in a plain text format to the data storage mechanism. Umbraco UI Builder can help with this by allowing you to define properties as encrypted. After which any time the value is persisted or retrieved from persistence, Umbraco UI Builder will automatically encrypt and decrypt the value.
7+
Umbraco UI Builder allows encrypting properties to store sensitive information securely. When a property is marked as encrypted, its value is automatically encrypted before storage and decrypted upon retrieval.
88

99
{% hint style="info" %}
10-
Umbraco UI Builder uses the `IDataProtectionProvider` instance registered in the DI container to perform its encryption/decryption. If you need to change the encryption algorithm, you should replace the `IDataProtectionProvider` instance in the DI container.
10+
Umbraco UI Builder uses the `IDataProtectionProvider` instance registered in the DI container for encryption and decryption. To modify the encryption algorithm, replace the `IDataProtectionProvider` instance in the DI container.
1111
{% endhint %}
1212

13-
## Defining encrypted properties
13+
## Defining Encrypted Properties
1414

15-
### **AddEncryptedProperty(Lambda encryptedPropertyExpression) : CollectionConfigBuilder<TEntityType>**
15+
### Using the `AddEncryptedProperty()` Method
1616

17-
Adds the given property to the encrypted properties collection. Property must be of type `String`. When set, the property will be encrypted/decrypted on write/read respectively.
17+
Encrypts the specified property. The property must be of type `String`. The value is encrypted before storage and decrypted when retrieved.
18+
19+
#### Method Syntax
20+
21+
```csharp
22+
AddEncryptedProperty(Lambda encryptedPropertyExpression) : CollectionConfigBuilder<TEntityType>
23+
```
24+
25+
#### Example
1826

1927
````csharp
20-
// Example
2128
collectionConfig.AddEncryptedProperty(p => p.Secret);
2229
````

15/umbraco-ui-builder/advanced/repositories.md

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
description: Configuring repositories in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Configure repositories in Umbraco UI Builder.
33
---
44

55
# Repositories
66

7-
Repositories are used by Umbraco UI Builder to access the entity data stores. By default, collections will use a generic built-in NPoco repository. However, you can define your own repository implementation should you wish to store your entities via an alternative strategy.
7+
Repositories in Umbraco UI Builder manage entity data storage. By default, collections use a built-in NPoco repository. To use a different storage strategy, define a custom repository implementation.
88

9-
## Defining a repository
9+
## Defining a Repository
1010

11-
To define a repository create a class that inherits from the base class `Repository<TEntity, TId>` and implements all of its abstract methods.
11+
Create a class that inherits from `Repository<TEntity, TId>` and implements all abstract methods.
1212

1313
````csharp
1414
// Example
@@ -58,39 +58,62 @@ public class PersonRepository : Repository<Person, int> {
5858
}
5959
````
6060

61-
**Note:** For all `Impl` methods there are public alternatives without the `Impl` suffix. However, there are separate implementation methods in order to ensure all repositories fire the relevant Umbraco UI Builder events. This is whether triggered via the Umbraco UI Builder's UI or not.
61+
{% hint style="info" %}
62+
`Impl` methods have public alternatives without the suffix. Separate implementation methods ensure repositories trigger Umbraco UI Builder events, whether actions originate from the UI or not.
63+
{% endhint %}
6264

63-
## Changing the repository implementation of a collection
65+
## Changing the Repository Implementation of a Collection
6466

65-
### **SetRepositoryType&lt;TRepositoryType&gt;() : CollectionConfigBuilder&lt;TEntityType&gt;**
67+
### Using the `SetRepositoryType()` Method
6668

67-
Sets the repository type to the given type for the current collection.
69+
Assign a custom repository type to a collection.
70+
71+
#### Method Syntax
72+
73+
```cs
74+
SetRepositoryType<TRepositoryType>() : CollectionConfigBuilder<TEntityType>
75+
```
76+
77+
#### Example
6878

6979
````csharp
70-
// Example
7180
collectionConfig.SetRepositoryType<PersonRepositoryType>();
7281
````
7382

74-
### **SetRepositoryType(Type repositoryType) : CollectionConfigBuilder&lt;TEntityType&gt;**
83+
### Using the `SetRepositoryType(Type repositoryType)` Method
7584

76-
Sets the repository type to the given type for the current collection.
85+
Sets the repository type dynamically to the given type for the current collection.
86+
87+
#### Method Syntax
88+
89+
```cs
90+
SetRepositoryType(Type repositoryType) : CollectionConfigBuilder<TEntityType>
91+
```
92+
93+
#### Example
7794

7895
````csharp
79-
// Example
8096
collectionConfig.SetRepositoryType(typeof(PersonRepositoryType));
8197
````
8298

83-
## Accessing a repository in code
99+
## Accessing a Repository in Code
84100

85101
To help with accessing a repository (default or custom) Umbraco UI Builder has an `IRepositoryFactory` you can inject into your code base. This includes a couple of factory methods to create the repository instances for you.
86102
Repositories should only be created via the repository factory as there are some injected dependencies that can only be resolved by Umbraco UI Builder.
87103

88-
### **IRepositoryFactory.GetRepository&lt;TEntity, TId&gt;() : Repository&lt;TEntity, TId&gt;**
104+
### Using the `GetRepository<TEntity, TId>()` Method
89105

90106
Creates a repository for the given entity type. Umbraco UI Builder will search the configuration for the first section/collection with a configuration for the given entity type. Then it will use that as a repository configuration.
91107

108+
#### Method Syntax
109+
110+
```cs
111+
IRepositoryFactory.GetRepository<TEntity, TId>() : Repository<TEntity, TId>
112+
```
113+
114+
#### Example
115+
92116
````csharp
93-
// Example
94117
public class MyController : Controller
95118
{
96119
private readonly Repository<Person, int> _repo;
@@ -102,12 +125,19 @@ public class MyController : Controller
102125
}
103126
````
104127

105-
### **IRepositoryFactory.GetRepository&lt;TEntity, TId&gt;(string collectionAlias) : Repository&lt;TEntity, TId&gt;**
128+
### Using the `GetRepository<TEntity, TId>(string collectionAlias)` Method
106129

107130
Creates a repository for the given entity type from the collection with the given alias.
108131

132+
#### Method Syntax
133+
134+
```cs
135+
IRepositoryFactory.GetRepository<TEntity, TId>(string collectionAlias) : Repository<TEntity, TId>
136+
```
137+
138+
#### Example
139+
109140
````csharp
110-
// Example
111141
public class MyController : Controller
112142
{
113143
private readonly Repository<Person, int> _repo;
Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
---
2-
description: Configuring value mappers in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Configuring value mappers in Umbraco UI Builder to modify how data is stored and retrieved.
33
---
44

55
# Value Mappers
66

7-
A value mapper is an Umbraco UI Builder helper class that sits between the editor UI and the database. It also lets you tweak the stored value of a field. By default Umbraco UI Builder will save a datatype value as it would be stored in Umbraco. Value mappers let you change this.
7+
Value mappers in Umbraco UI Builder act as intermediaries between the editor UI and the database, allowing customization of stored field values. By default, Umbraco UI Builder saves data as it would be stored in Umbraco, but value mappers enable modifications.
88

9-
When Umbraco UI Builder resolves a value mapper it will attempt to do so from the global DI container. This means you can inject any dependencies that you require for your mapper. If there is no type defined in the DI container, Umbraco UI Builder will fall-back to manually instantiating a new instance of value mapper.
9+
When resolving a value mapper, Umbraco UI Builder first checks the global DI container. If no type is defined, it manually instantiates a new instance.
1010

11-
## Defining a value mapper
11+
## Defining a Value Mapper
1212

13-
To define a mapper create a class that inherits from the base class `ValueMapper` and implements the methods `EditorToModel` and `ModelToEditor`.
13+
To define a mapper, create a class that inherits from the base class `ValueMapper` and implements the `EditorToModel` and `ModelToEditor` methods.
14+
15+
### Example
1416

1517
````csharp
16-
// Example
1718
public class MyValueMapper : ValueMapper
1819
{
1920
public override object EditorToModel(object input)
@@ -30,33 +31,54 @@ public class MyValueMapper : ValueMapper
3031
}
3132
````
3233

33-
## Setting a field value mapper
34+
## Setting a Field Value Mapper
3435

3536
Value mappers are defined as part of a collection editor field configuration.
3637

37-
### **SetValueMapper&lt;TMapperType&gt;() : EditorFieldConfigBuilder&lt;TEntityType, TValueType&gt;**
38+
### Using the `SetValueMapper()` Method
3839

3940
Set the value mapper for the current field.
4041

42+
#### Method Syntax
43+
44+
```csharp
45+
SetValueMapper<TMapperType>() : EditorFieldConfigBuilder<TEntityType, TValueType>
46+
```
47+
48+
#### Example
49+
4150
````csharp
42-
// Example
4351
fieldConfig.SetValueMapper<MyValueMapper>();
4452
````
4553

46-
### **SetValueMapper(Type mapperType) : EditorFieldConfigBuilder&lt;TEntityType, TValueType&gt;**
54+
### Using the `SetValueMapper(Type mapperType)` Method
4755

48-
Set the value mapper for the current field.
56+
Set the value mapper for the current field using a type reference.
57+
58+
#### Method Syntax
59+
60+
```csharp
61+
SetValueMapper(Type mapperType) : EditorFieldConfigBuilder<TEntityType, TValueType>
62+
```
63+
64+
#### Example
4965

5066
````csharp
51-
// Example
5267
fieldConfig.SetValueMapper(typeof(MyValueMapper));
5368
````
5469

55-
### **SetValueMapper(Mapper mapper) : EditorFieldConfigBuilder&lt;TEntityType, TValueType&gt;**
70+
### Using the `SetValueMapper(Mapper mapper)` Method
5671

57-
Set the value mapper for the current field.
72+
Set the value mapper for the current field using an instance.
73+
74+
#### Method Syntax
75+
76+
```csharp
77+
SetValueMapper(Mapper mapper) : EditorFieldConfigBuilder<TEntityType, TValueType>
78+
```
79+
80+
#### Example
5881

5982
````csharp
60-
// Example
6183
fieldConfig.SetValueMapper(new MyValueMapper());
6284
````

0 commit comments

Comments
 (0)