public ImmutableMultiDictionary <TKey, TValue> Create <TKey, TValue>(params KeyValuePair <TKey, TValue>[] entries) { var builder = ImmutableSetMultiDictionary <TKey, TValue> .Builder(); builder.PutAll(entries); return(builder.Build()); }
/// <summary> /// Converts dictionary to ImmutableSetMultiDictionary. /// </summary> /// <typeparam name="TKey">Type of dictionary key</typeparam> /// <typeparam name="TValue">Type of dictionary value</typeparam> /// <param name="source">this</param> /// <returns>ImmutableSetMultiDictionary</returns> public static ImmutableSetMultiDictionary <TKey, TValue> ToImmutableSetMultiDictionary <TKey, TValue>( this IReadOnlyDictionary <TKey, TValue> source) { Preconditions.IsNotNull(source, () => new ArgumentNullException("source")); var builder = ImmutableSetMultiDictionary <TKey, TValue> .Builder(); builder.PutAll(source); return(builder.Build()); }
/// <summary> /// Converts MultiDictionary to ImmutableSetMultiDictionary. /// If MultiDictionary is already ImmutableSetMultiDictionary returns it. /// </summary> /// <typeparam name="TKey">Type of dictionary key</typeparam> /// <typeparam name="TValue">Type of dictionary value</typeparam> /// <param name="source">Converted MultiDictionary</param> /// <returns>ImmutableSetMultiDictionary</returns> public static ImmutableSetMultiDictionary <TKey, TValue> ToImmutableSetMultiDictionary <TKey, TValue>( this MultiDictionary <TKey, TValue> source) { Preconditions.IsNotNull(source, () => new ArgumentNullException("source")); if (source is ImmutableSetMultiDictionary <TKey, TValue> ) { return((ImmutableSetMultiDictionary <TKey, TValue>)source); } var result = ImmutableSetMultiDictionary <TKey, TValue> .Builder(); result.PutAll(source); return(result.Build()); }