コード例 #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));
        }
コード例 #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);
        }
コード例 #3
0
        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);
        }