BioLib  4.3.0
A GUI-less version of Bio .NET library for editing & annotating various microscopy image formats.
Loading...
Searching...
No Matches
BioLib.Settings Class Reference

Static Public Member Functions

static string GetSettings (string name)
 The function "GetSettings" returns the value associated with a given name from a dictionary, or an empty string if the name is not found.
 
static void AddSettings (string name, string val)
 The function "AddSettings" adds a name-value pair to the "Default" dictionary.
 
static void Save ()
 The Save function writes the key-value pairs from the Default dictionary to a text file.
 
static void Load ()
 The Load function reads settings from a file and adds them to a dictionary.
 

Member Function Documentation

◆ AddSettings()

static void BioLib.Settings.AddSettings ( string name,
string val )
static

The function "AddSettings" adds a name-value pair to the "Default" dictionary.

Parameters
nameThe name parameter is a string that represents the name of the setting.
valThe "val" parameter is a string value that represents the value to be added to the settings.
53 {
54 if(Default.ContainsKey((string)name))
55 Default[name] = val;
56 else
57 Default.Add(name, val);
58 }

◆ GetSettings()

static string BioLib.Settings.GetSettings ( string name)
static

The function "GetSettings" returns the value associated with a given name from a dictionary, or an empty string if the name is not found.

Parameters
nameThe name parameter is a string that represents the name of the setting that you want to retrieve.
Returns
The method is returning a string value. If the specified name exists in the Default dictionary, the corresponding value is returned. Otherwise, an empty string is returned.
40 {
41 if(Default.ContainsKey(name)) return Default[name];
42 return "";
43 }

◆ Load()

static void BioLib.Settings.Load ( )
static

The Load function reads settings from a file and adds them to a dictionary.

Returns
If the file "Settings.txt" does not exist, the method will return without doing anything.
79 {
80 if (!File.Exists(path + "/Settings.txt"))
81 return;
82 string[] sts = File.ReadAllLines(path + "/Settings.txt");
83 foreach (string item in sts)
84 {
85 string[] st = item.Split('=');
86 if (Default.ContainsKey(st[0]))
87 Default[st[0]] = st[1];
88 else
89 Default.Add(st[0], st[1]);
90 }
91 }
static List< string > sts
Definition Bio.cs:10698

◆ Save()

static void BioLib.Settings.Save ( )
static

The Save function writes the key-value pairs from the Default dictionary to a text file.

63 {
64 string val = "";
65 foreach (var item in Default)
66 {
67 val += item.Key + "=" + item.Value + Environment.NewLine;
68 }
69 File.WriteAllText(path + "/Settings.txt", val);
70 }

The documentation for this class was generated from the following file: