/// <summary>
 /// Adds an entry with the specified <paramref name="key"/> and <paramref name="value"/>. An exception is thrown in an entry already exists.
 /// </summary>
 /// <param name="collection">The collection to add the entry to.</param>
 /// <param name="key">The key of the entry to add.</param>
 /// <param name="value">The value to add.</param>
 /// <exception cref="InvalidOperationException">Thrown if an entry with the specified <paramref name="key"/> already exists.</exception>
 public static void Add <TKey, TValue>(this IReactiveEntityCollection <TKey, TValue> collection, TKey key, TValue value)
 {
     if (!collection.TryAdd(key, value))
     {
         throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "An entry with key '{0}' already exists.", key));
     }
 }
Ejemplo n.º 2
0
 public ExternalLookupReactiveEntityCollection(IReactiveEntityCollection <string, TDefinitionEntity> local, TryLookup <IReactiveMetadata, string, TDefinitionEntity> lookupFunc, IReactiveMetadata external)
     : base(local, lookupFunc, external)
 {
 }
 public BlockingCollection(IEqualityComparer <TKey> comparer, EventWaitHandle blockAdd, EventWaitHandle blockRemove)
 {
     _inner       = new ReactiveEntityCollection <TKey, TValue>(comparer);
     _blockAdd    = blockAdd;
     _blockRemove = blockRemove;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a reactive entity collection wrapping a specified underlying collection and a fallback function.
 /// </summary>
 /// <param name="local">The underlying collection to use for lookups.</param>
 /// <param name="tryLookup">The fallback function to use in case lookup in the collection fails.</param>
 /// <param name="arg">The argument to pass to the fallback function (avoids a closure).</param>
 public CooperativeLookupReactiveEntityCollection(IReactiveEntityCollection <TKey, TValue> local, TryLookup <TArg, TKey, TValue> tryLookup, TArg arg)
 {
     _local     = local;
     _tryLookup = tryLookup;
     _arg       = arg;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new reactive entity collection using a primary and secondary (fallback) underlying collection.
 /// </summary>
 /// <param name="collection">The first underlying collection to look up entities.</param>
 /// <param name="otherCollection">The second underlying collection to fall back to if lookup for an entity fails in the first collection.</param>
 /// <param name="convertOther">Conversion function to make the second underlying collection's values compatible with the first underlying collection's values.</param>
 public ChainedLookupReactiveEntityCollection(IReactiveEntityCollection <TKey, TValue> collection, IReactiveEntityCollection <TKey, TOtherValue> otherCollection, Func <TOtherValue, TValue> convertOther)
     : base(collection, TryLookupOther, Tuple.Create(otherCollection, convertOther))
 {
 }
 private static void Add <TEntity>(IReactiveEntityCollection <string, TEntity> collection, TEntity entity)
     where TEntity : ReactiveEntity
 {
     collection.Add(entity.Uri.ToCanonicalString(), entity);
 }
Ejemplo n.º 7
0
 public Impl(IReactiveEntityCollection <TKey, TValue> collection) => _collection = collection;
Ejemplo n.º 8
0
 public static ITypeErasedDictionary <TKey, TValue> ToReadOnly <TKey, TValue>(IReactiveEntityCollection <TKey, TValue> collection)
 {
     return(new Impl <TKey, TValue>(collection));
 }
Ejemplo n.º 9
0
 public WrappedEntityCollection(IReactiveEntityCollection <string, T> parent, Func <T, R> conversion, RegistryOptions options)
 {
     _parent     = parent;
     _conversion = conversion;
     _options    = options;
 }
Ejemplo n.º 10
0
 public WrappedEntityCollection(IReactiveEntityCollection <string, T> parent, Func <T, R> conversion)
     : this(parent, conversion, new RegistryOptions())
 {
 }