public bool Save(string name, VStancerPreset preset) { // Check if the preset and the ID are valid if (string.IsNullOrEmpty(name) || preset == null) { return(false); } // Get the KVP key string key = string.Concat(mKvpPrefix, name); // Be sure the key isn't already used if (GetResourceKvpString(key) != null) { return(false); } // Get the Json var json = JsonConvert.SerializeObject(preset); // Save the KVP SetResourceKvp(key, json); // Invoke the event PresetsCollectionChanged?.Invoke(this, EventArgs.Empty); return(true); }
public bool Delete(string name) { // Check if the preset ID is valid if (string.IsNullOrEmpty(name)) { return(false); } // Get the KVP key string key = string.Concat(mKvpPrefix, name); // Check if a KVP with the given key exists if (GetResourceKvpString(key) == null) { return(false); } // Delete the KVP DeleteResourceKvp(key); // Invoke the event PresetsCollectionChanged?.Invoke(this, EventArgs.Empty); return(true); }