Converting a nested dictionary to IReadOnlyDictionary
<p>I am trying to give out a <code>IReadOnly</code>-references to internal <code>Collection</code> objects.
This works well in most cases, but does not if i want to convert a dictionary containing a collection into an <code>IReadOnlyDictionary</code> containing a <code>IReadOnlyCollection</code>.</p>

<p>Here a code example:</p>

<pre><code>    var list = new List&lt;int&gt;();
    IReadOnlyList&lt;int&gt; listReference = list; //works;

    var dictionary = new Dictionary&lt;int, int&gt;();
    IReadOnlyDictionary&lt;int, int&gt; dictionaryReference = dictionary; //works

    var nestedList = new List&lt;List&lt;int&gt;&gt;();
    IReadOnlyList&lt;IReadOnlyList&lt;int&gt;&gt; nestedReadOnlyListReference = nestedList; //works

    var nestedDictionary = new Dictionary&lt;int, List&lt;int&gt;&gt;();
    //IReadOnlyDictionary&lt;int, IReadOnlyList&lt;int&gt;&gt; nestedReadOnlyDictionaryReference = nestedDictionary; //does not work, can not implicitly convert

    //current workaround
    var nestedDictionaryReferenceHelper = new Dictionary&lt;int, IReadOnlyList&lt;int&gt;&gt;();
    foreach (var kvpNestedDictionary in nestedDictionary)
    {
        nestedDictionaryReferenceHelper.Add(kvpNestedDictionary.Key, (IReadOnlyList&lt;int&gt;)kvpNestedDictionary.Value);
    }
    IReadOnlyDictionary&lt;int, IReadOnlyList&lt;int&gt;&gt; nestedReadOnlyDictionaryReference = nestedDictionaryReferenceHelper; //works, but is only a reference to the internal List, not to the dictionary itself
</code></pre>

<p>The workaround is pretty ugly as it needs additional memory and needs manual updating every time the values of <code>nestedDictionary</code> change.</p>

<p>Is there any simple way to convert such nested dictionaries?</p>