blob: 4c6169a4e838211cc5df7aa0b9c44a5dc42b111c (
plain)
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
|
// 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.Security;
using System.Collections;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
namespace System.Runtime.InteropServices.WindowsRuntime
{
// Local definition of Windows.Foundation.IClosable
[ComImport]
[Guid("30d5a829-7fa4-4026-83bb-d75bae4ea99e")]
[WindowsRuntimeImport]
internal interface IClosable
{
void Close();
}
// Adapter class - converts IClosable.Close calls to Disposable.Dispose
internal sealed class IDisposableToIClosableAdapter
{
private IDisposableToIClosableAdapter()
{
Debug.Assert(false, "This class is never instantiated");
}
public void Close()
{
IDisposable _this = JitHelpers.UnsafeCast<IDisposable>(this);
_this.Dispose();
}
}
// Adapter class which converts IDisposable.Dispose calls into IClosable.Close
internal sealed class IClosableToIDisposableAdapter
{
private IClosableToIDisposableAdapter()
{
Debug.Assert(false, "This class is never instantiated");
}
private void Dispose()
{
IClosable _this = JitHelpers.UnsafeCast<IClosable>(this);
_this.Close();
}
}
}
|