Build

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.

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();
}

Last updated