|
using System.Core.Collections;
namespace System.Core.Emit
{
/// <summary>
/// Factory class used to create new instances of the <seealso cref="DynamicAccessor"/> class.
/// </summary>
/// <remarks>
/// The factory class will only create a DynamicAccessor once for each type.
/// If the request for a type is made twice, the cached DynamicAccessor will be returned.
/// </remarks>
public static class DynamicAccessorFactory
{
/// <summary>
/// A collection of DynamicAccessors indexed by type
/// </summary>
private readonly static HybridCollection<Type, IDynamicAccessor> _DynamicAccessors = new HybridCollection<Type, IDynamicAccessor>();
/// <summary>
/// Returns a reference to a DynamicAccessor for the requested type represented by <seealso cref="IDynamicAccessor"/>.
/// </summary>
/// <param name="type">The for to get the DynamicAccessor</param>
/// <returns><see cref="DynamicAccessor"/></returns>
public static IDynamicAccessor GetDynamicAccessor(Type type)
{
if (!_DynamicAccessors.Contains(type))
_DynamicAccessors.Add(type,new DynamicAccessor(type));
return _DynamicAccessors[type];
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm a 39 year old software developer living in Norway.
I'm currently working for a software company making software for the retail industry.