Ejemplo n.º 1
0
        public Task <BlueprintStorage> LoadBlueprint(Guid blueprintId)
        {
            BlueprintRegistryItem item = RegistryItemListManager.GetRegistryItem(blueprintId);

            if (item == null)
            {
                return(Task.FromResult(null as BlueprintStorage));
            }
            string           json    = FileSystem.ReadAllText(item.FilePath);
            BlueprintStorage storage = ConvertFromJSON(json, item);

            return(Task.FromResult(storage));
        }
Ejemplo n.º 2
0
        private BlueprintStorage ConvertFromJSON(string fileJson, BlueprintRegistryItem item)
        {
            if (string.IsNullOrWhiteSpace(fileJson))
            {
                return(null);
            }
            BlueprintStorage storage = JsonConvert.DeserializeObject <BlueprintStorage>(fileJson);

            storage.StorageType           = Constants.StorageType.Local;
            storage.BlueprintRegistryItem = item;
            string json = CryptoService.Decrypt(storage.Data, item.Key);

            storage.Blueprint = JsonConvert.DeserializeObject <Blueprint>(json);
            return(storage);
        }
        public void CreateNewBlueprint()
        {
            IBlueprint blueprint = ServiceProvider.GetService <IBlueprint>();

            ActiveBlueprintStorage = new BlueprintStorage()
            {
                Id                    = blueprint.Id,
                StorageType           = Constants.StorageType.UnSaved,
                Blueprint             = blueprint,
                BlueprintRegistryItem = new BlueprintRegistryItem()
                {
                    Id   = blueprint.Id,
                    Key  = AppSettings.LocalEncryptionKey,
                    Name = blueprint.Name
                }
            };
            ActiveBlueprintStorage.BlueprintRegistryItem.SetFilePath(AppSettings.DefaultSaveFolder);
            ChangeContentPage(Constants.ContentPage.CreateBlueprint);
            OnLoadedBlueprint?.Invoke(this, blueprint);
        }