public void AddStorageItem(StateStorageItem item) { string error; if (!TryAddStorageItem(item, out error)) { throw new InvalidDataException(error); } }
public bool TryAddStorageItem(StateStorageItem item, out string errorMessage) { if (!item.IsValid()) { errorMessage = string.Format("Invalid storage item: {0}", item.LogString()); return(false); } if (!Items.TryAdd(item.ItemName, item)) { errorMessage = string.Format("An item with name '{0}' already exists", item.ItemName); return(false); } errorMessage = null; return(true); }
public bool TryGetItem(string key, out StateStorageItem item) { return(Items.TryGetValue(key, out item)); }
public bool TryAddStorageItem(StateStorageItem item) { string error; return(TryAddStorageItem(item, out error)); }