Exemple #1
0
        private string ConvertToJSON(IBlueprintStorage blueprintStorage)
        {
            string json = JsonConvert.SerializeObject((Blueprint)blueprintStorage.Blueprint);

            blueprintStorage.Data = CryptoService.Encrypt(json, blueprintStorage.BlueprintRegistryItem.Key);
            return(JsonConvert.SerializeObject(blueprintStorage));
        }
Exemple #2
0
 private void SyncSettingsFromBlueprintToStorageObjects(IBlueprintStorage blueprintStorage)
 {
     if (string.IsNullOrWhiteSpace(blueprintStorage.Blueprint.Name))
     {
         blueprintStorage.Blueprint.Name = $"Id:{blueprintStorage.Id}";
     }
     blueprintStorage.BlueprintRegistryItem.Name = blueprintStorage.Blueprint.Name;
 }
Exemple #3
0
        public async Task VerifySaveBlueprint()
        {
            IBlueprintLoaderService service = GetBlueprintLoaderService(out IAppSettings appSettings);
            IBlueprintStorage       storage = GetBlueprintStorage("Test A");

            Assert.True(await service.SaveBlueprint(storage));
            // blueprint is expected to be added to registry list that is used to remember and load blueprints from
            Assert.Single(appSettings.BlueprintList);
        }
Exemple #4
0
        public async Task VerifyLoadBlueprint()
        {
            IBlueprintLoaderService service = GetBlueprintLoaderService(out IAppSettings appSettings);
            // First we need to save our test blueprint so we have something to load
            IBlueprintStorage storage = GetBlueprintStorage("Test A");

            Assert.True(await service.SaveBlueprint(storage));

            // Load first blueprint from list in app settings
            BlueprintStorage loaded = await service.LoadBlueprint(appSettings.BlueprintList[0].Id);

            Assert.Equal(storage.Id, loaded.BlueprintRegistryItem.Id);
            Assert.Equal(storage.Blueprint.Name, loaded.Blueprint.Name);
        }
        public void OpenBlueprint(Guid blueprintId)
        {
            ChangeContentPage(Constants.ContentPage.Loading);
            IBlueprintStorage storage = LoaderService.LoadBlueprint(blueprintId).GetAwaiter().GetResult();

            if (storage == null)
            {
                UpdateStatus($"Failed to open Blueprint!");
                ChangeContentPage(Constants.ContentPage.Error);
                return;
            }
            ActiveBlueprintStorage = storage;
            ChangeContentPage(Constants.ContentPage.ViewBlueprint);
            ListManager.PrependRegistryItemToList((BlueprintRegistryItem)ActiveBlueprintStorage.BlueprintRegistryItem);
            OnLoadedBlueprint?.Invoke(this, ActiveBlueprintStorage.Blueprint);
        }
Exemple #6
0
        private Task <bool> SaveBlueprintToLocalFileSystem(IBlueprintStorage blueprintStorage)
        {
            if (string.IsNullOrWhiteSpace(blueprintStorage.BlueprintRegistryItem.Key))
            {
                blueprintStorage.BlueprintRegistryItem.Key = Guid.NewGuid().ToString();
            }
            if (!FileSystem.IsValidDirectory(blueprintStorage.BlueprintRegistryItem.FilePath))
            {
                return(Task.FromResult(false));
            }
            string fileJson = ConvertToJSON(blueprintStorage);

            RegistryItemListManager.PrependRegistryItemToList((BlueprintRegistryItem)blueprintStorage.BlueprintRegistryItem);
            FileSystem.SaveFileToDirectory(blueprintStorage.BlueprintRegistryItem.FilePath, fileJson);
            return(Task.FromResult(true));
        }
Exemple #7
0
 public async Task <bool> SaveBlueprint(IBlueprintStorage blueprintStorage)
 {
     SyncSettingsFromBlueprintToStorageObjects(blueprintStorage);
     return(await SaveBlueprintToLocalFileSystem(blueprintStorage));
 }