Table of Contents

Class AppDataBase<StorageFolder, StorageFile>

Namespace
SunamoPlatformUwpInterop.AppData
Assembly
SunamoPlatformUwpInterop.dll

Base class for application data management providing settings storage, folder management and initialization of application directories.

public abstract class AppDataBase<StorageFolder, StorageFile> : IAppDataBase<StorageFolder, StorageFile>

Type Parameters

StorageFolder

The type representing a storage folder.

StorageFile

The type representing a storage file.

Inheritance
AppDataBase<StorageFolder, StorageFile>
Implements
IAppDataBase<StorageFolder, StorageFile>
Derived
Inherited Members
Extension Methods

Fields

FolderWithAppsFiles

The file name used to store the path to the folder containing application files.

public const string FolderWithAppsFiles = "folderWithAppsFiles.txt"

Field Value

string

rootFolder

After startup will be set up in AppData/Roaming. Then from folderWithAppsFilesPath the app can load an alternative path. For all apps either AppData/Roaming or the alternative path will be valid.

protected StorageFolder rootFolder

Field Value

StorageFolder

rootFolderPa

The root folder for the parent application.

protected StorageFolder rootFolderPa

Field Value

StorageFolder

Properties

BasePath

Gets or sets the base path for the application data.

public string? BasePath { get; set; }

Property Value

string

LoadedCommonSettings

Gets or sets the dictionary of loaded common settings.

public Dictionary<string, string>? LoadedCommonSettings { get; set; }

Property Value

Dictionary<string, string>

LoadedSettingsBool

Gets or sets the dictionary of loaded boolean settings.

public Dictionary<string, bool>? LoadedSettingsBool { get; set; }

Property Value

Dictionary<string, bool>

LoadedSettingsDateTime

Gets or sets the dictionary of loaded DateTime settings.

public Dictionary<string, DateTime>? LoadedSettingsDateTime { get; set; }

Property Value

Dictionary<string, DateTime>

LoadedSettingsList

Gets or sets the dictionary of loaded list settings.

public Dictionary<string, List<string>>? LoadedSettingsList { get; set; }

Property Value

Dictionary<string, List<string>>

LoadedSettingsOther

Gets or sets the dictionary of loaded string settings.

public Dictionary<string, string>? LoadedSettingsOther { get; set; }

Property Value

Dictionary<string, string>

RijndaelBytesEncrypt

Gets or sets the Rijndael encryption function for byte lists.

public static Func<List<byte>, List<byte>>? RijndaelBytesEncrypt { get; set; }

Property Value

Func<List<byte>, List<byte>>

RootFolder

Gets or sets the root folder for the application data. This path already includes ThisApp.Name. Use with caution and always ensure you are not setting it to empty string.

public StorageFolder RootFolder { get; set; }

Property Value

StorageFolder

RootFolderPa

Gets or sets the root folder for the parent application.

public StorageFolder RootFolderPa { get; set; }

Property Value

StorageFolder

SunamoFolder

Gets or sets the Sunamo folder path.

public string? SunamoFolder { get; set; }

Property Value

string

Methods

AppendAllText(AppFolders, string, string)

Appends text content to a file in the specified application folder.

public Task AppendAllText(AppFolders appFolders, string fileName, string value)

Parameters

appFolders AppFolders

The application folder category.

fileName string

The file name.

value string

The text to append.

Returns

Task

AppendAllText(string, string)

Appends text content to the specified file path.

public Task AppendAllText(string filePath, string value)

Parameters

filePath string

The path of the file to append to.

value string

The text to append.

Returns

Task

CreateAppFoldersIfDontExists(CreateAppFoldersIfDontExistsArgs)

Creates application folders if they do not exist and loads all specified settings. If a key is prefixed with '!', the value will be decrypted using the provided Rijndael function.

public void CreateAppFoldersIfDontExists(CreateAppFoldersIfDontExistsArgs args)

Parameters

args CreateAppFoldersIfDontExistsArgs

The arguments specifying the application name, settings keys and encryption functions.

GetFileCommonSettings(string)

Gets the file path for common settings. Must return always string, not StorageFile. In .NET Standard there is no StorageFile class and it is impossible to get Path.

public abstract string GetFileCommonSettings(string key)

Parameters

key string

The settings key.

Returns

string

The file path for the common settings file.

GetFileInSubfolder(AppFolders, string, string, string)

Gets the file path in a subfolder within the specified application folder.

public abstract StorageFile GetFileInSubfolder(AppFolders appFolders, string subfolder, string fileName, string extension)

Parameters

appFolders AppFolders

The application folder category.

subfolder string

The subfolder name.

fileName string

The file name without extension.

extension string

The file extension.

Returns

StorageFile

The full file path.

GetFolder(AppFolders)

Gets the path for the specified application folder.

public abstract StorageFolder GetFolder(AppFolders appFolders)

Parameters

appFolders AppFolders

The application folder category.

Returns

StorageFolder

The folder path.

GetFolderWithAppsFiles()

Gets the path to the file that stores the folder with application files configuration.

public string GetFolderWithAppsFiles()

Returns

string

The path to the folder with apps files configuration file.

GetPathForSettingsFile(string)

Gets the path for a settings file with the given key.

public string GetPathForSettingsFile(string key)

Parameters

key string

The settings key.

Returns

string

The full file path to the settings file.

GetSunamoFolder()

Gets the Sunamo folder path. Must be here as Task because in UWP everything is async.

public abstract StorageFolder GetSunamoFolder()

Returns

StorageFolder

The Sunamo folder path.

ReadFileOfSettingsBool(string)

Reads a boolean settings value for the specified key. If the file does not exist or has empty content, creates it with false value.

public bool ReadFileOfSettingsBool(string key)

Parameters

key string

The settings key.

Returns

bool

The boolean settings value.

ReadFileOfSettingsDateTime(string)

Reads a DateTime settings value for the specified key.

public DateTime ReadFileOfSettingsDateTime(string key)

Parameters

key string

The settings key.

Returns

DateTime

The DateTime settings value.

ReadFileOfSettingsExistingDirectoryOrFile(string)

Reads a settings file value for an existing directory or file key. If the file does not exist, creates it with empty content.

public string ReadFileOfSettingsExistingDirectoryOrFile(string key)

Parameters

key string

The settings key.

Returns

string

The settings value.

ReadFileOfSettingsWorker<T>(IDictionary<string, T>, string)

Reads a value from the specified settings dictionary.

public T ReadFileOfSettingsWorker<T>(IDictionary<string, T> settingsDictionary, string key)

Parameters

settingsDictionary IDictionary<string, T>

The dictionary to read from.

key string

The settings key.

Returns

T

The settings value.

Type Parameters

T

The type of the settings value.

ReadFolderWithAppsFilesOrDefault()

Reads the folder with apps files path or returns the default value.

public string? ReadFolderWithAppsFilesOrDefault()

Returns

string

The folder path or default value.

RootFolderCommon(bool)

Gets the root folder path for common application data.

public abstract string RootFolderCommon(bool isInFolderCommon)

Parameters

isInFolderCommon bool

Whether to return the Common subfolder path.

Returns

string

The common root folder path.

SaveFile(AppFolders, string, string)

Saves a file with the specified contents to the given application folder.

public Task<StorageFile> SaveFile(AppFolders appFolders, string fileName, string value)

Parameters

appFolders AppFolders

The application folder category.

fileName string

The file name.

value string

The content to write.

Returns

Task<StorageFile>

The storage file that was saved to.

SaveFileOfSettings(string, string)

Saves a string value to a settings file.

public Task SaveFileOfSettings(string fileName, string value)

Parameters

fileName string

The settings file name (without extension).

value string

The value to save.

Returns

Task

SaveFileOfSettingsBool(string, bool)

Saves a boolean value to a settings file.

public Task SaveFileOfSettingsBool(string key, bool value)

Parameters

key string

The settings key.

value bool

The boolean value to save.

Returns

Task

SaveFileOfSettingsDateTime(string, DateTime)

Saves a DateTime value to a settings file.

public Task SaveFileOfSettingsDateTime(string key, DateTime dateTime)

Parameters

key string

The settings key.

dateTime DateTime

The DateTime value to save.

Returns

Task

SaveFileOfSettingsList(string, IEnumerable<string>)

Saves a list of strings to a settings file.

public Task SaveFileOfSettingsList(string key, IEnumerable<string> enumerable)

Parameters

key string

The settings key.

enumerable IEnumerable<string>

The enumerable of strings to save.

Returns

Task