Table of Contents

Class AppData

Namespace
SunamoPlatformUwpInterop.AppData
Assembly
SunamoPlatformUwpInterop.dll

Provides application data management for desktop applications. Manages root folders, settings files, and common configuration.

public class AppData : AppDataAbstractBase<string, string>, IAppDataBase<string, string>
Inheritance
AppData
Implements
Inherited Members
Extension Methods

Fields

Instance

Singleton instance of the AppData class.

public static AppData Instance

Field Value

AppData

Methods

AppendAllText(AppFolders, string, string)

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

public override 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 the specified content to the given file path.

public override Task AppendAllText(string content, string filePath)

Parameters

content string

The text content to append.

filePath string

The path of the file to append to.

Returns

Task

CreateForApp(string, string)

Creates an AppData instance configured for a specific application.

public static AppData CreateForApp(string rootFolderFromCreatedAppData, string appName)

Parameters

rootFolderFromCreatedAppData string

The root folder from an existing AppData instance.

appName string

The target application name.

Returns

AppData

A new AppData instance configured for the specified application.

GetCommonSettings(string, bool)

Gets a common settings value for the specified key. Each application must specify which keys it uses. They are loaded at application startup and nothing related to settings is loaded after initialization.

public override string GetCommonSettings(string key, bool isCrypted = true)

Parameters

key string

The settings key.

isCrypted bool

Whether the value is encrypted.

Returns

string

The common settings value.

GetFile(AppFolders, string)

Gets the file path for the specified file in the given application folder.

public override string GetFile(AppFolders appFolders, string fileName)

Parameters

appFolders AppFolders

The application folder category.

fileName string

The file name.

Returns

string

The file path.

GetFileAppTypeAgnostic(AppFolders, string)

Gets the file path in a folder that is application type agnostic (uses parent app folder).

public string GetFileAppTypeAgnostic(AppFolders appFolders, string fileName)

Parameters

appFolders AppFolders

The application folder category.

fileName string

The file name.

Returns

string

The file path.

GetFileCommonSettings(string)

Gets the file path for common settings. Without extension because all values are encrypted and stored in bytes.

public override string GetFileCommonSettings(string fileName)

Parameters

fileName string

The settings file name.

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 override string 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

string

The full file path.

GetFileString(string, string)

Gets the file path for the specified application folder name and file name.

public string GetFileString(string appFolderName, string fileName)

Parameters

appFolderName string

The application folder name as a string.

fileName string

The file name.

Returns

string

The file path.

GetFileString(string, string, bool)

Gets the file path as a string for the specified application folder name and file name.

public override string GetFileString(string appFolderName, string fileName, bool isUsingParentAppFolder = false)

Parameters

appFolderName string

The application folder name as a string.

fileName string

The file name.

isUsingParentAppFolder bool

Whether to use the parent application root folder.

Returns

string

The file path as a string.

GetFolder(AppFolders)

Gets the path for the specified application folder.

public override string GetFolder(AppFolders appFolders)

Parameters

appFolders AppFolders

The application folder category.

Returns

string

The folder path ending with a backslash.

GetRootFolder(string)

Gets or creates the root folder for the application with the specified name. Also creates the parent application folder.

public override string GetRootFolder(string appName)

Parameters

appName string

The application name.

Returns

string

The root folder path.

GetRootFolderForApp(string, string)

Gets the root folder for a different application based on an existing root folder.

public string GetRootFolderForApp(string rootFolderFromCreatedAppData, string appName)

Parameters

rootFolderFromCreatedAppData string

The existing application's root folder.

appName string

The name of the target application.

Returns

string

The root folder path for the target application.

GetSunamoFolder()

Gets the Sunamo folder path from the configuration file. Falls back to AppData\Roaming\sunamo if not configured.

public override string GetSunamoFolder()

Returns

string

The Sunamo folder path.

IsRootFolderNull()

Checks whether the root folder is null or empty. The root folder is set in GetRootFolder which is called only from CreateAppFoldersIfDontExists.

public override bool IsRootFolderNull()

Returns

bool

True if the root folder is null or empty; otherwise false.

IsRootFolderOk()

Checks whether the root folder exists in the file system.

public override bool IsRootFolderOk()

Returns

bool

True if the root folder exists; otherwise false.

ReadFileOfSettingsList(string)

Reads a list of strings from the settings file for the specified key.

public List<string> ReadFileOfSettingsList(string key)

Parameters

key string

The settings key.

Returns

List<string>

The list of strings from the settings file.

RootFolderCommon(bool)

Gets the common root folder path, always located in User's AppData.

public override string RootFolderCommon(bool isInFolderCommon)

Parameters

isInFolderCommon bool

Whether to return the Common subfolder path.

Returns

string

The common root folder path.

SaveFile(string, string)

Saves the specified content to the given file path.

protected override Task SaveFile(string content, string filePath)

Parameters

content string

The text content to save.

filePath string

The path of the file to save to.

Returns

Task

SetCommonSettings(string, string)

Sets an encrypted common settings value for the specified key.

public override void SetCommonSettings(string key, string value)

Parameters

key string

The settings key.

value string

The value to encrypt and store.