1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace System.Runtime.InteropServices.WindowsRuntime
{
// Provides access to a System.Collections.Generic.KeyValuePair<K, V> via the IKeyValuePair<K, V> WinRT interface.
internal sealed class CLRIKeyValuePairImpl<K, V> : IKeyValuePair<K, V>,
IGetProxyTarget
{
private readonly KeyValuePair<K, V> _pair;
public CLRIKeyValuePairImpl([In] ref KeyValuePair<K, V> pair)
{
_pair = pair;
}
// IKeyValuePair<K, V> implementation
[Pure]
public K Key
{
get { return _pair.Key; }
}
[Pure]
public V Value
{
get { return _pair.Value; }
}
// Called from the VM to wrap a boxed KeyValuePair with a CLRIKeyValuePairImpl.
internal static object BoxHelper(object pair)
{
Contract.Requires(pair != null);
KeyValuePair<K, V> unboxedPair = (KeyValuePair<K, V>)pair;
return new CLRIKeyValuePairImpl<K, V>(ref unboxedPair);
}
// Called from the VM to get a boxed KeyValuePair out of a CLRIKeyValuePairImpl.
internal static object UnboxHelper(object wrapper)
{
Contract.Requires(wrapper != null);
CLRIKeyValuePairImpl<K, V> reference = (CLRIKeyValuePairImpl<K, V>)wrapper;
return reference._pair;
}
public override string ToString()
{
return _pair.ToString();
}
object IGetProxyTarget.GetTarget()
{
return _pair;
}
}
}
|