blob: 638a46972ba8721e2961018603585581f1b9b3d0 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// -----------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.ComponentModel.Composition.Primitives;
namespace System.ComponentModel.Composition.Factories
{
partial class PartFactory
{
// NOTE: Do not add any more behavior to this class, as ComposablePartTests.cs
// uses this to verify default behavior of the base class.
private class DisposableComposablePart : ComposablePart, IDisposable
{
private readonly Action<bool> _disposeCallback;
public DisposableComposablePart(Action<bool> disposeCallback)
{
Assert.IsNotNull(disposeCallback);
_disposeCallback = disposeCallback;
}
public void Dispose()
{
this.Dispose(true);
}
~DisposableComposablePart()
{
Dispose(false);
}
protected virtual void Dispose(bool disposing)
{
_disposeCallback(disposing);
}
public override IEnumerable<ImportDefinition> ImportDefinitions
{
get { return Enumerable.Empty<ImportDefinition>(); }
}
public override IEnumerable<ExportDefinition> ExportDefinitions
{
get { return Enumerable.Empty<ExportDefinition>(); }
}
public override object GetExportedValue(ExportDefinition definition)
{
Assert.Fail();
return null;
}
public override void SetImport(ImportDefinition definition, IEnumerable<Export> exports)
{
Assert.Fail();
}
public override IDictionary<string, object> Metadata
{
get { return new Dictionary<string, object>(); }
}
}
}
}
|