Extensions
Contains extension methods that do not require a special using directive.
using System;
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace NUnit.Framework
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal static class Extensions
{
public static bool IsStatic(this Type type)
{
if (type.IsAbstract)
return type.IsSealed;
return false;
}
public static bool HasAttribute<[System.Runtime.CompilerServices.Nullable(2)] T>(this ICustomAttributeProvider attributeProvider, bool inherit)
{
return attributeProvider.IsDefined(typeof(T), inherit);
}
public static bool HasAttribute<[System.Runtime.CompilerServices.Nullable(2)] T>(this Type type, bool inherit)
{
return ((ICustomAttributeProvider)type).HasAttribute<T>(inherit);
}
public static T[] GetAttributes<T>(this ICustomAttributeProvider attributeProvider, bool inherit) where T : class
{
return (T[])attributeProvider.GetCustomAttributes(typeof(T), inherit);
}
public static T[] GetAttributes<T>(this Assembly assembly) where T : class
{
return assembly.GetAttributes<T>(false);
}
public static T[] GetAttributes<T>(this Type type, bool inherit) where T : class
{
return ((ICustomAttributeProvider)type).GetAttributes<T>(inherit);
}
public static IEnumerable Skip(this IEnumerable enumerable, long skip)
{
IEnumerator iterator = enumerable.GetEnumerator();
using (iterator as IDisposable) {
while (true) {
long num = skip;
skip = num - 1;
if (num <= 0)
break;
if (!iterator.MoveNext())
yield break;
}
while (iterator.MoveNext()) {
yield return iterator.Current;
}
}
}
}
}