Ejemplo n.º 1
0
        private async Task <Dictionary <Type, Dictionary <int, SerializedModel> > > LoadStringModels(Type contextType,
                                                                                                     IEnumerable <PropertyInfo> storageSets)
        {
            Dictionary <Type, Dictionary <int, SerializedModel> > stringModels = new Dictionary <Type, Dictionary <int, SerializedModel> >();

            foreach (PropertyInfo prop in storageSets)
            {
                Type modelType = prop.PropertyType.GetGenericArguments()[0];
                Dictionary <int, SerializedModel> map = new Dictionary <int, SerializedModel>();
                string   storageTableName             = Util.GetStorageTableName(contextType, modelType);
                Metadata metadata = await _storageManagerUtil.LoadMetadata(storageTableName);

                if (metadata == null)
                {
                    continue;
                }

                foreach (Guid guid in metadata.Guids)
                {
                    string name            = $"{storageTableName}-{guid}";
                    string serializedModel = await _blazorDBInterop.GetItem(name, false);

                    int id = FindIdInSerializedModel(serializedModel);
                    map.Add(id, new SerializedModel {
                        StringModel = serializedModel
                    });
                }

                stringModels.Add(modelType, map);
            }

            return(stringModels);
        }
Ejemplo n.º 2
0
        public async Task <Metadata> LoadMetadata(string storageTableName)
        {
            string name  = $"{storageTableName}-{Metadata}";
            string value = await _blazorDBInterop.GetItem(name, false);

            return(value != null?JsonSerializer.Deserialize <Metadata>(value) : null);
        }