Exemplo 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));
        }
Exemplo n.º 2
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));
        }