update MEF to preview 9
[mcs.git] / class / System.ComponentModel.Composition / src / Composition.Initialization / System / ComponentModel / Composition / ExportFactoryOfT.cs
blob1ee66281ff965fd7127c96e6f3ff7cedeb2dbf79
1 // -----------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // -----------------------------------------------------------------------
4 using System;
5 using Microsoft.Internal;
6 using System.ComponentModel.Composition.Primitives;
8 namespace System.ComponentModel.Composition
10 public class ExportFactory<T>
12 private Func<Tuple<T, Action>> _exportLifetimeContextCreator;
14 public ExportFactory(Func<Tuple<T, Action>> exportLifetimeContextCreator)
16 if (exportLifetimeContextCreator == null)
18 throw new ArgumentNullException("exportLifetimeContextCreator");
21 this._exportLifetimeContextCreator = exportLifetimeContextCreator;
24 public ExportLifetimeContext<T> CreateExport()
26 Tuple<T, Action> untypedLifetimeContext = this._exportLifetimeContextCreator.Invoke();
27 return new ExportLifetimeContext<T>(untypedLifetimeContext.Item1, untypedLifetimeContext.Item2);