示例#1
0
        public void AddStorageItem(StateStorageItem item)
        {
            string error;

            if (!TryAddStorageItem(item, out error))
            {
                throw new InvalidDataException(error);
            }
        }
示例#2
0
 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);
 }
示例#3
0
 public bool TryGetItem(string key, out StateStorageItem item)
 {
     return(Items.TryGetValue(key, out item));
 }
示例#4
0
        public bool TryAddStorageItem(StateStorageItem item)
        {
            string error;

            return(TryAddStorageItem(item, out error));
        }