> For the complete documentation index, see [llms.txt](https://tariksavas.gitbook.io/tarsave/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tariksavas.gitbook.io/tarsave/docs/how-to-use/datapersistencebuilder/build.md).

# Build

```csharp
DataPersistenceService Build()
```

**Purpose:** This method is used to construct and return a fully configured `DataPersistenceService`. This service handles the saving, loading, and deletion of data based on the configuration provided.

**Parameters:** None

`Return Value`: Returns a fully configured `DataPersistenceService` instance if the configuration is valid, otherwise returns `null`.

**Key Behavior:**

* Validates the provided configuration.
* Dynamically creates and configures components for encryption, compression, streaming, and serialization based on the configuration.
* Returns the `DataPersistenceService` that combines these components to handle data operations.

```csharp
public void BuildService()
{
    AESCryptographyConfig aesConfig = 
        ScriptableObject.CreateInstance<AESCryptographyConfig>();
        
    DataPersistenceConfig config = 
        ScriptableObject.CreateInstance<DataPersistenceConfig>();
    
    config.encryption = true;
    config.compression = true;
    config.aesCryptographyConfig = aesConfig;

    DataPersistenceService service = new DataPersistenceBuilder()
        .SetDataPersistenceConfig(config)
        .Build();
}
```
