Beispiel #1
0
 /// <summary>
 /// Atomically adds a new item to the map.
 /// If the key already exists then the Fail handler is called with the unaltered map
 /// and the value already set for the key, it expects a new map returned.
 /// </summary>
 /// <remarks>Null is not allowed for a Key or a Value</remarks>
 /// <param name="key">Key</param>
 /// <param name="value">Value</param>
 /// <param name="Fail">Delegate to handle failure, you're given the unaltered map
 /// and the value already set for the key</param>
 /// <exception cref="ArgumentNullException">Throws ArgumentNullException the key or value are null</exception>
 /// <returns>New Map with the item added</returns>
 public static Map <K, V> tryAdd <K, V>(Map <K, V> map, K key, V value, Func <Map <K, V>, V, Map <K, V> > Fail) =>
 map.TryAdd(key, value, Fail);
 /// <summary>
 /// Attempts to set a meta-data item.  If it is already set, nothing
 /// happens.
 ///
 /// This is for extending the default strategies behaviours and
 /// allows for state to survive in-between Process errors
 /// </summary>
 public StrategyState TrySetMetaData <T>(string key, T value) =>
 With(Metadata: Metadata.TryAdd(key, value));
Beispiel #3
0
 /// <summary>
 /// Atomically adds a new item to the map.
 /// If the key already exists, then the new item is ignored
 /// </summary>
 /// <remarks>Null is not allowed for a Key or a Value</remarks>
 /// <param name="key">Key</param>
 /// <param name="value">Value</param>
 /// <exception cref="ArgumentNullException">Throws ArgumentNullException the key or value are null</exception>
 /// <returns>New Map with the item added</returns>
 public static Map <K, V> tryAdd <K, V>(Map <K, V> map, K key, V value) =>
 map.TryAdd(key, value);