-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIObjectFactory.cs
More file actions
87 lines (82 loc) · 3.29 KB
/
IObjectFactory.cs
File metadata and controls
87 lines (82 loc) · 3.29 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================
using System;
using System.Collections.Generic;
namespace RapidField.SolidInstruments.ObjectComposition
{
/// <summary>
/// Encapsulates creation of new object instances using explicit types.
/// </summary>
/// <typeparam name="ProductTBase">
/// The base type from which all produced types derive.
/// </typeparam>
public interface IObjectFactory<ProductTBase> : IObjectFactory
{
/// <summary>
/// Creates a new instance of an object of the specified type.
/// </summary>
/// <typeparam name="TProduct">
/// The explicit type of the object to create.
/// </typeparam>
/// <returns>
/// A new instance of an object of the specified type.
/// </returns>
/// <exception cref="ArgumentException">
/// <typeparamref name="TProduct" /> is not a supported product type for the factory.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
/// <exception cref="ObjectProductionException">
/// An exception was raised during object production.
/// </exception>
public TProduct Produce<TProduct>()
where TProduct : class, ProductTBase;
/// <summary>
/// Gets the base type from which all produced types derive.
/// </summary>
public Type ProductBaseType
{
get;
}
}
/// <summary>
/// Encapsulates creation of new object instances using explicit types.
/// </summary>
public interface IObjectFactory : IAsyncDisposable, IDisposable
{
/// <summary>
/// Creates a new instance of an object of the specified type.
/// </summary>
/// <param name="type">
/// The explicit type of the object to create.
/// </param>
/// <returns>
/// A new instance of an object of the specified type.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="type" /> is not a supported product type for the factory.
/// </exception>
/// <exception cref="ArgumentNullException">
/// <paramref name="type" /> is <see langword="null" />.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
/// <exception cref="ObjectProductionException">
/// An exception was raised during object production.
/// </exception>
public Object Produce(Type type);
/// <summary>
/// Gets the types that can be produced by the current <see cref="IObjectFactory{TProductBase}" />.
/// </summary>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public IEnumerable<Type> SupportedProductTypes
{
get;
}
}
}