internal static async Task <Metadata> LoadMetadata(string storageTableName) { var name = $"{storageTableName}-{Metadata}"; var value = await BlazorDBInterop.GetItem(name, false); return(value != null?Json.Deserialize <Metadata>(value) : null); }
private static Dictionary <Type, Dictionary <int, SerializedModel> > LoadStringModels(Type contextType, IEnumerable <PropertyInfo> storageSets) { var stringModels = new Dictionary <Type, Dictionary <int, SerializedModel> >(); foreach (var prop in storageSets) { var modelType = prop.PropertyType.GetGenericArguments()[0]; var map = new Dictionary <int, SerializedModel>(); var storageTableName = Util.GetStorageTableName(contextType, modelType); var metadata = StorageManagerUtil.LoadMetadata(storageTableName); if (metadata == null) { continue; } foreach (var guid in metadata.Guids) { var name = $"{storageTableName}-{guid}"; var serializedModel = BlazorDBInterop.GetItem(name, false); var id = FindIdInSerializedModel(serializedModel); map.Add(id, new SerializedModel { StringModel = serializedModel }); } stringModels.Add(modelType, map); } return(stringModels); }
public static Metadata LoadMetadata(string storageTableName) { var name = $"{storageTableName}-{METADATA}"; var value = BlazorDBInterop.GetItem(name, false); return(value != null?JsonUtil.Deserialize <Metadata>(value) : null); }
private static void DeleteOldModelsFromStorage(Metadata metadata, string storageTableName) { foreach (var guid in metadata.Guids) { var name = $"{storageTableName}-{guid}"; BlazorDBInterop.RemoveItem(name, false); } }
private void SaveMetadata(string storageTableName, List <Guid> guids, Type context, Type modelType) { var metadata = new Metadata { Guids = guids, ContextName = Util.GetFullyQualifiedTypeName(context), ModelName = Util.GetFullyQualifiedTypeName(modelType) }; var name = $"{storageTableName}-{StorageManagerUtil.METADATA}"; BlazorDBInterop.SetItem(name, JsonUtil.Serialize(metadata), false); }
private static async void SaveMetadata(string storageTableName, List <Guid> guids, Type context, Type modelType, Metadata oldMetadata) { var metadata = new Metadata { Guids = guids, ContextName = Util.GetFullyQualifiedTypeName(context), ModelName = Util.GetFullyQualifiedTypeName(modelType), MaxId = oldMetadata.MaxId }; var name = $"{storageTableName}-{StorageManagerUtil.Metadata}"; await BlazorDBInterop.SetItem(name, Json.Serialize(metadata), false); }
private List <Guid> SaveModels(object storageSetValue, Type modelType, string storageTableName, List <PropertyInfo> storageSets) { var guids = new List <Guid>(); var storageSetType = StorageManagerUtil.genericStorageSetType.MakeGenericType(modelType); var method = storageSetType.GetMethod(StorageManagerUtil.GET_ENUMERATOR); var enumerator = (IEnumerator)method.Invoke(storageSetValue, new object[] { }); while (enumerator.MoveNext()) { var guid = Guid.NewGuid(); guids.Add(guid); var model = enumerator.Current; var name = $"{storageTableName}-{guid}"; var serializedModel = ScanModelForAssociations(model, storageSets, JsonUtil.Serialize(model)); BlazorDBInterop.SetItem(name, serializedModel, false); } return(guids); }