First create a struct for the Model and a Provider to serve it, there are ready to use base classes to derive from:
You then use the [Persist] attribute to select the CacheMode and the [PersistValue] attribute to select which properties should be preserved and how they should be initialized
public class ExampleProvider : IStoreProviderLocalStorage<ExampleModel> { public ExampleProvider(string containerPath) : base(containerPath) { } } [Persist(PersistType.Cache)] public struct ExampleModel { [PersistValue(false)] public bool exampleBoolean { get; set; } [PersistValue("InitValue")] public string exampleString { get; set; } }
After you designed your Provider and Model you can create the Store, and register the Provider
StoreEngine.Store MyStore = new StoreEngine.Store(); MyStore.RegisterProvider("Examples", new ExampleProvider("ExampleData"));
The store is address based, and the Models are now available with the path Examples.* , inside the LocalStore the objects will be located in a Container called "ExampleData" (see Constructor of Provider)
Modifications of the Store is now very easy
var firstExample = MyStore.Create<ExampleModel>("Examples.FirstExample"); var secondExample = MyStore.Create<ExampleModel>("Examples.SecondExample"); var thirdExample = MyStore.Create<ExampleModel>("Examples.ThirdExample"); firstExample.exampleString = "Hi!"; MyStore.Update("Examples.FirstExample", firstExample); MyStore.Delete("Examples.ThirdExample"); var tmpExample = Mystore.Read<ExampleModel>("Examples.FirstExample"); secondExample.exampleString = tmpExample.exampleString; Mystore.Update("Examples.SecondExample", secondExample);
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4