blob: 2e7fdbb8a747602a4b0e54ee87650e2305606070 (
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
|
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
namespace WixToolset.Extensibility
{
using System;
using System.Collections.Generic;
/// <summary>
/// Base class for extension factories.
/// </summary>
public abstract class BaseExtensionFactory : IExtensionFactory
{
protected abstract IEnumerable<Type> ExtensionTypes { get; }
public virtual bool TryCreateExtension(Type extensionType, out object extension)
{
extension = null;
foreach (var type in this.ExtensionTypes)
{
if (extensionType.IsAssignableFrom(type))
{
extension = Activator.CreateInstance(type);
break;
}
}
return extension != null;
}
}
}
|