Class CategoryNameGroup<T>
Base class for Category Name databases
Inheritance
Inherited Members
Namespace: Doozy.Runtime.Common
Assembly: cs.temp.dll.dll
Syntax
public class CategoryNameGroup<T>
where T : CategoryNameItem, new()
Type Parameters
Name | Description |
---|---|
T | Type of CategoryNameItem |
Properties
defaultCategory
Default string value for Category
Declaration
public static string defaultCategory { get; }
Property Value
Type | Description |
---|---|
String |
defaultName
Default string value for Name
Declaration
public static string defaultName { get; }
Property Value
Type | Description |
---|---|
String |
isEmpty
Check if the database is empty.
This also add an entry with the default category and name values (if it's missing)
Declaration
public bool isEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
items
List of all the items (entries) in the database
Declaration
public List<T> items { get; }
Property Value
Type | Description |
---|---|
List<T> |
Methods
AddCategory(String)
Add a new item to the database with the given category value and the default name value
Declaration
public bool AddCategory(string category)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
Returns
Type | Description |
---|---|
Boolean | True if the operation was successful and false otherwise |
AddName(String, String)
Add a new item to the database with the given category and name values
Declaration
public bool AddName(string category, string name)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
String | name | Name value |
Returns
Type | Description |
---|---|
Boolean | True if the operation was successful and false otherwise |
CanAddCategory(String)
Check if the given category value can be added as an entry in the database
Declaration
public (bool, string) CanAddCategory(string category)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
Returns
Type | Description |
---|---|
(T1, T2)<Boolean, String> | Operation result (True or False) and a success or failure reason message |
CanAddName(String, String)
Check if an entry with the given category and name values can be added as an entry in the database
Declaration
public (bool, string) CanAddName(string category, string name)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
String | name | Name value |
Returns
Type | Description |
---|---|
(T1, T2)<Boolean, String> | Operation result (True or False) and a success or failure reason message |
CanRemoveCategory(String)
Check if the given category value can be removed from the database
Declaration
public (bool, string) CanRemoveCategory(string category)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
Returns
Type | Description |
---|---|
(T1, T2)<Boolean, String> | Operation result (True or False) and a success or failure reason message |
CanRemoveName(String, String)
Check if the entry with the given category and name values can be removed from the database
Declaration
public (bool, string) CanRemoveName(string category, string name)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
String | name | Name value |
Returns
Type | Description |
---|---|
(T1, T2)<Boolean, String> | Operation result (True or False) and a success or failure reason message |
CanRenameCategory(String, String)
Check if the given category name can be renamed to the new category name.
Declaration
public (bool, string) CanRenameCategory(string oldCategory, string newCategory)
Parameters
Type | Name | Description |
---|---|---|
String | oldCategory | Old category name |
String | newCategory | New category value |
Returns
Type | Description |
---|---|
(T1, T2)<Boolean, String> | Operation result (True or False) and a success or failure reason message |
CleanDatabase()
Remove null or empty entries and sort the group by category and then by name
Declaration
public void CleanDatabase()
CleanString(String, Boolean, Boolean)
Cleans the string by removing any empty spaces (at the start of the string and/or the end of the string)
Declaration
public static string CleanString(string value, bool removeWhitespaces = true, bool removeSpecialCharacters = true)
Parameters
Type | Name | Description |
---|---|---|
String | value | Target value |
Boolean | removeWhitespaces | Remove all whitespaces from the target string |
Boolean | removeSpecialCharacters | Remove all special characters from the target string |
Returns
Type | Description |
---|---|
String | The cleaned string |
ClearDatabase()
Clears the database and adds an entry with the default values
Declaration
public void ClearDatabase()
ContainsCategory(String)
Check if the database contains an entry for the given category value
Declaration
public bool ContainsCategory(string category)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
Returns
Type | Description |
---|---|
Boolean | True if there is an item with the given category in the database, otherwise it returns false |
ContainsName(String, String)
Check if the database contains an entry for the given category and name values
Declaration
public bool ContainsName(string category, string name)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
String | name | Name value |
Returns
Type | Description |
---|---|
Boolean | True if an entry was found and false otherwise |
Get(String, String)
Get data for the given category and name. Returns null if not found
Declaration
public T Get(string category, string name)
Parameters
Type | Name | Description |
---|---|---|
String | category | Target category |
String | name | Target name |
Returns
Type | Description |
---|---|
T | The entry if found, null otherwise |
GetCategories()
Get all the category names, sorted alphabetically
Declaration
public IEnumerable<string> GetCategories()
Returns
Type | Description |
---|---|
IEnumerable<String> |
GetNames(String)
Get all the names inside the given category
Declaration
public IEnumerable<string> GetNames(string category)
Parameters
Type | Name | Description |
---|---|---|
String | category | Target category |
Returns
Type | Description |
---|---|
IEnumerable<String> |
RemoveCategory(String)
Remove all the items from the database with the given category value
Declaration
public bool RemoveCategory(string category)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
Returns
Type | Description |
---|---|
Boolean | True if the operation was successful and false otherwise |
RemoveName(String, String)
Remove the database entry with the given category and name value
Declaration
public bool RemoveName(string category, string name)
Parameters
Type | Name | Description |
---|---|---|
String | category | Category value |
String | name | Name value |
Returns
Type | Description |
---|---|
Boolean | True if the operation was successful and false otherwise |
RenameCategory(String, String)
Rename the given category value to the new category value
Declaration
public bool RenameCategory(string oldCategory, string newCategory)
Parameters
Type | Name | Description |
---|---|---|
String | oldCategory | Old category value |
String | newCategory | New category value |
Returns
Type | Description |
---|---|
Boolean | True if the operation was successful and false otherwise |