5.4 KiB
TODO List: Local Storage and Data Management for .szf Data
Phase 1: Local Storage and SZF Serialization Foundation
-
Task: Create a Local Storage Service
-
Description: Implement a service to abstract browser
localStorage
interactions for storing and retrieving string data. This will likely involve Blazor JavaScript interop. -
Files Affected/Created:
Services/ILocalStorageService.cs
(new interface)Services/LocalStorageService.cs
(new implementation)
-
Context: This service will be the low-level API for
localStorage
. It will handle saving and loading the raw .szf string content.
-
-
Task: Develop SZF Object Converter/Serializer Helper
-
Description: Create a utility class or static methods to convert
Character
,Dataset
, andCharacterTemplate
objects to and from their string representations. This should leverage the existingPopulateFromMetadata
,ParseSections
,GenerateMetadata
, andGenerateContent
methods within these classes..szf
-
Files Affected/Created:
Utils/SzfConverter.cs
(new static class)
-
Context: , , all have methods for processing SZF sections. This helper will orchestrate using those methods for full object serialization/deserialization to/from a single string. The will be crucial here for understanding the file structure.
Character.cs``Dataset.cs``CharacterTemplate.cs``szf-documentation.md
-
Phase 2: SZF Data Repository and Retrieval Logic
-
Task: Design and Implement SZF Data Repository
-
Description: Create a central service that manages all loaded entities (
Character
,Dataset
,CharacterTemplate
). It will use theILocalStorageService
to persist data and theSzfConverter
to handle object-to-string conversions..szf
-
Files Affected/Created:
Services/ISzfDataRepository.cs
(new interface)Services/SzfDataRepository.cs
(new implementation)
-
Context: This is the core of the data management. It will hold collections of all available entities and provide methods for querying them.
-
-
Task: Implement Retrieval Methods in
SzfDataRepository
-
Description: Add methods to
SzfDataRepository
for retrieving stored entities based on various criteria. -
Methods to Implement:
Save<T>(T entity)
: Persists aCharacter
,Dataset
, orCharacterTemplate
instance to local storage.LoadAllSzfEntities()
: Loads all known data (characters, datasets, templates) from local storage into the repository's in-memory collections on application startup..szf
GetCharacter(Guid guid, Version version)
: Retrieves a specificCharacter
by its template GUID and version.GetDataset(Guid guid, Version version)
: Retrieves a specificDataset
by its GUID and version (from metadata).GetCharacterTemplate(Guid guid, Version version)
: Retrieves a specificCharacterTemplate
by its GUID and version (from metadata).GetDatasetsByType(string datasetType)
: Retrieves allDataset
instances of a specific type (e.g., "items", "spells").FindCharactersByName(string name)
: Finds characters by name (may return multiple).FindDatasetsByName(string name)
: Finds datasets by name (may return multiple).FindCharacterTemplatesByName(string name)
: Finds character templates by name (may return multiple).
-
Files Affected/Created:
Services/SzfDataRepository.cs
-
Context: The explicitly mentions GUID, version, name, and type for data management. , , and all contain the necessary metadata fields (like
Guid
,TemplateGuid
,Version
,Name
,DatasetType
) to support these retrieval methods.technical-specifications.md``Character.cs``Dataset.cs``CharacterTemplate.cs
-
Phase 3: Integration and Relationship Resolution
-
Task: Integrate Data Loading with Core Models
-
Description: Modify
Character
,CharacterTemplate
, andDataset
classes, or create factory methods for them, to use theSzfDataRepository
for loading. -
Files Affected/Created:
Character.cs
Dataset.cs
CharacterTemplate.cs
-
Context: When a
Character
is loaded, it will need to retrieve its associatedCharacterTemplate
. When aCharacterTemplate
is loaded, it will need to resolve itsRequiredDatasets
. This is where the relationships outlined in and come into play. TheDatasetReference
class in andRequiredDatasetReference
in are key for this.technical-specifications.md``szf-documentation.md``Dataset.cs``CharacterTemplate.cs
-
-
Task: Implement Relationship Resolution Logic
-
Description: Ensure that when a
Character
is loaded, itsTemplateGuid
andTemplateVersion
are used to load the correctCharacterTemplate
from theSzfDataRepository
. Similarly, ensureCharacterTemplate
objects correctly resolve theirRequiredDatasets
. -
Files Affected/Created:
Character.cs
CharacterTemplate.cs
Services/SzfDataRepository.cs
(might need helper methods for resolution)
-
Context: The user explicitly mentioned "relationship between character>character_template>dataset". This task addresses that. The
DatasetReference
class will be crucial for parsing the strings from the .szf files and then using theSzfDataRepository
to fetch the actualDataset
objects.Name|GUID|Version
-