コード例 #1
0
        public async Task <int> SaveContextToLocalStorage(StorageContext context)
        {
            var total       = 0;
            var contextType = context.GetType();
            await Logger.ContextSaved(contextType);

            var storageSets = StorageManagerUtil.GetStorageSets(contextType);
            var error       = ValidateModels(context, storageSets);

            if (error == null)
            {
                var metadataMap = await LoadMetadataList(context, storageSets, contextType);

                total = await SaveStorageSets(context, total, contextType, storageSets, metadataMap);

                Logger.EndGroup();
            }
            else
            {
                await BlazorLogger.Logger.Error("SaveChanges() terminated due to validation error");

                Logger.EndGroup();
                throw new BlazorDBUpdateException(error);
            }

            return(total);
        }
コード例 #2
0
        public int SaveContextToLocalStorage(StorageContext context)
        {
            int total       = 0;
            var contextType = context.GetType();

            Logger.ContextSaved(contextType);
            var storageSets = StorageManagerUtil.GetStorageSets(contextType);

            total = SaveStorageSets(context, total, contextType, storageSets);
            Logger.EndGroup();
            return(total);
        }
コード例 #3
0
ファイル: StorageManagerLoad.cs プロジェクト: larshg/BlazorDB
        public void LoadContextFromStorageOrCreateNew(IServiceCollection serviceCollection, Type contextType)
        {
            Logger.StartContextType(contextType);
            var storageSets  = StorageManagerUtil.GetStorageSets(contextType);
            var stringModels = LoadStringModels(contextType, storageSets);

            //PrintStringModels(stringModels);
            stringModels = ScanNonAssociationModels(storageSets, stringModels);
            stringModels = ScanAssociationModels(storageSets, stringModels);
            stringModels = DeserializeModels(stringModels, storageSets);
            //PrintStringModels(stringModels);
            var context = CreateContext(contextType, stringModels);

            RegisterContext(serviceCollection, contextType, context);
            Logger.EndGroup();
        }
コード例 #4
0
        public async Task LoadContextFromLocalStorage(StorageContext context)
        {
            var contextType = context.GetType();
            await Logger.StartContextType(contextType);

            var storageSets  = StorageManagerUtil.GetStorageSets(contextType);
            var stringModels = await LoadStringModels(contextType, storageSets);

            //PrintStringModels(stringModels);
            stringModels = ScanNonAssociationModels(storageSets, stringModels);
            stringModels = ScanAssociationModels(storageSets, stringModels);
            stringModels = DeserializeModels(stringModels, storageSets);
            //PrintStringModels(stringModels);
            await EnrichContext(context, contextType, stringModels);

            Logger.EndGroup();
        }