Nullable: System.Runtime.InteropServices.CustomMarshalers/WindowsRuntime (#23930)
[platform/upstream/coreclr.git] / src / System.Private.CoreLib / src / System / Runtime / InteropServices / WindowsRuntime / IMap.cs
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.
4
5 #nullable enable
6 using System.Collections.Generic;
7
8 // Windows.Foundation.Collections.IMap`2, IMapView`2, and IKeyValuePair`2 cannot be referenced from
9 // managed code because they're hidden by the metadata adapter. We redeclare the interfaces manually
10 // to be able to talk to native WinRT objects.
11
12 namespace System.Runtime.InteropServices.WindowsRuntime
13 {
14     [ComImport]
15     [Guid("3c2925fe-8519-45c1-aa79-197b6718c1c1")]
16     [WindowsRuntimeImport]
17     internal interface IMap<K, V> : IIterable<IKeyValuePair<K, V>>
18     {
19         V Lookup(K key);
20         uint Size { get; }
21         bool HasKey(K key);
22         IReadOnlyDictionary<K, V> GetView();  // Really an IMapView<K, V>
23         bool Insert(K key, V value);
24         void Remove(K key);
25         void Clear();
26     }
27
28     [ComImport]
29     [Guid("e480ce40-a338-4ada-adcf-272272e48cb9")]
30     [WindowsRuntimeImport]
31     internal interface IMapView<K, V> : IIterable<IKeyValuePair<K, V>>
32     {
33         V Lookup(K key);
34         uint Size { get; }
35         bool HasKey(K key);
36         void Split(out IMapView<K, V>? first, out IMapView<K, V>? second);
37     }
38
39     [ComImport]
40     [Guid("02b51929-c1c4-4a7e-8940-0312b5c18500")]
41     [WindowsRuntimeImport]
42     internal interface IKeyValuePair<K, V>
43     {
44         K Key { get; }
45         V Value { get; }
46     }
47 }