Class Storage
StorageService - centralized persistent data storage. Uses type-specific dictionaries to avoid casting. Optimized for performance with O(1) lookups.
[Serializable]
public class Storage : IStorageService, IServiceBase
- Inheritance
-
Storage
- Implements
- Inherited Members
Constructors
Storage()
protected Storage()
Properties
Count
Gets the number of key/value pairs contained in the storage.
public int Count { get; }
Property Value
Instance
public static IStorageService Instance { get; }
Property Value
Keys
Gets a collection containing the keys in the storage.
public IEnumerable<string> Keys { get; }
Property Value
Methods
AddOrUpdate<T>(string, T)
Adds a key/value pair to the storage if the key does not already exist, or updates the value for an existing key.
public void AddOrUpdate<T>(string key, T value)
Parameters
keystringThey key to be added or whose value should be updated.
valueTThe value of the element to add, or update.
Type Parameters
T
ContainsKey<T>(string)
Determines whether the storage contains the specified key for the given type.
public bool ContainsKey<T>(string key)
Parameters
keystringThe key to locate in the storage.
Returns
Type Parameters
TThe type of the value to check.
Remove<T>(string)
Removes the value with the specified key from the storage for the given type.
public bool Remove<T>(string key)
Parameters
keystringThe key of the element to remove.
Returns
Type Parameters
TThe type of the value to remove.
Reset()
Initialize the service. This is called by the API when the service is first used.
public void Reset()
TryGetValue<T>(string, out T)
Gets the type-safe value associated with the specified key.
public bool TryGetValue<T>(string key, out T value)
Parameters
keystringThe key of the value to get.
valueTWhen this methods returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed unintialized.
Returns
Type Parameters
TThe type of object to retrieve.