Determines if the type implements the given interface.
//Microsoft Public License (Ms-PL)
//http://visualizer.codeplex.com/license
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Redwerb.BizArk.Core.TypeExt
{
/// <summary>
/// Provides extension methods for Type.
/// </summary>
public static class TypeExt
{
/// <summary>
/// Determines if the type implements the given interface.
/// </summary>
/// <param name="type"></param>
/// <param name="interfaceType"></param>
/// <returns></returns>
public static bool Implements(this Type type, Type interfaceType)
{
foreach (Type i in type.GetInterfaces())
if (i == interfaceType) return true;
return false;
}
}
}
Related examples in the same category