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
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
appFoldersAppFoldersThe application folder category.
fileNamestringThe file name.
valuestringThe text to append.
Returns
AppendAllText(string, string)
Appends the specified content to the given file path.
public override Task AppendAllText(string content, string filePath)
Parameters
Returns
CreateForApp(string, string)
Creates an AppData instance configured for a specific application.
public static AppData CreateForApp(string rootFolderFromCreatedAppData, string appName)
Parameters
rootFolderFromCreatedAppDatastringThe root folder from an existing AppData instance.
appNamestringThe 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
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
appFoldersAppFoldersThe application folder category.
fileNamestringThe 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
appFoldersAppFoldersThe application folder category.
fileNamestringThe 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
fileNamestringThe 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
appFoldersAppFoldersThe application folder category.
subfolderstringThe subfolder name.
fileNamestringThe file name without extension.
extensionstringThe 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
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
appFolderNamestringThe application folder name as a string.
fileNamestringThe file name.
isUsingParentAppFolderboolWhether 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
appFoldersAppFoldersThe 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
appNamestringThe 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
rootFolderFromCreatedAppDatastringThe existing application's root folder.
appNamestringThe 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
keystringThe settings key.
Returns
RootFolderCommon(bool)
Gets the common root folder path, always located in User's AppData.
public override string RootFolderCommon(bool isInFolderCommon)
Parameters
isInFolderCommonboolWhether 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
Returns
SetCommonSettings(string, string)
Sets an encrypted common settings value for the specified key.
public override void SetCommonSettings(string key, string value)