1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
6 using System.Collections.Generic;
7 using System.Diagnostics;
9 namespace System.Runtime.InteropServices.WindowsRuntime
11 // Provides access to a System.Collections.Generic.KeyValuePair<K, V> via the IKeyValuePair<K, V> WinRT interface.
12 internal sealed class CLRIKeyValuePairImpl<K, V> : IKeyValuePair<K, V>,
15 private readonly KeyValuePair<K, V> _pair;
17 public CLRIKeyValuePairImpl([In] ref KeyValuePair<K, V> pair)
22 // IKeyValuePair<K, V> implementation
25 get { return _pair.Key; }
30 get { return _pair.Value; }
33 // Called from the VM to wrap a boxed KeyValuePair with a CLRIKeyValuePairImpl.
34 internal static object BoxHelper(object pair)
36 Debug.Assert(pair != null);
38 KeyValuePair<K, V> unboxedPair = (KeyValuePair<K, V>)pair;
39 return new CLRIKeyValuePairImpl<K, V>(ref unboxedPair);
42 // Called from the VM to get a boxed KeyValuePair out of a CLRIKeyValuePairImpl.
43 internal static object UnboxHelper(object wrapper)
45 Debug.Assert(wrapper != null);
47 CLRIKeyValuePairImpl<K, V> reference = (CLRIKeyValuePairImpl<K, V>)wrapper;
48 return reference._pair;
51 public override string ToString()
53 return _pair.ToString();
56 object IGetProxyTarget.GetTarget()