|
using System;
using System.Collections.ObjectModel;
using Codebasement.DomainDrivenDesign.Basement.Attributes;
using Codebasement.DomainDrivenDesign.Basement.Basement;
namespace Codebasement.DomainDrivenDesign.Basement.Basement
{
/// <summary>
///
/// </summary>
public class RelatableObjectCollection : Collection<BasementObject>
{
private readonly Type _holderType;
/// <summary>
/// Initializes a new instance of the <see cref="RelatableObjectCollection"/> class.
/// </summary>
/// <param name="holderType">Type of the holder.</param>
public RelatableObjectCollection(Type holderType)
{
_holderType = holderType;
}
/// <summary>
/// Determines whether the specified type is defined.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>
/// <c>true</c> if the specified type is defined; otherwise, <c>false</c>.
/// </returns>
public bool IsDefined(Type type)
{
if (_holderType.IsDefined(typeof (RelatableAttribute), true))
{
RelatableAttribute[] relatableAttributes =
_holderType.GetCustomAttributes(
typeof (RelatableAttribute), true)
as RelatableAttribute[];
if (relatableAttributes != null)
{
foreach (RelatableAttribute relationAttribute in relatableAttributes)
{
if (relationAttribute.BasementObjectType == type)
{
return true;
}
}
}
}
return false;
}
}
}
|
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.