-
Notifications
You must be signed in to change notification settings - Fork 1
Empty ...
Pawel Gerr edited this page Mar 4, 2023
·
6 revisions
Convenience methods providing delegates of type Action<..>
with empty bodies.
public static void Main()
{
MyMethod_1(Empty.Action); // provides MyMethod_1 with an empty "Action"
MyMethod_2(Empty.Action); // provides MyMethod_2 with an empty "Action<string>"
}
private static void MyMethod_1(Action action)
{
...
}
private static void MyMethod_2(Action<string> action)
{
...
}
Convenience methods providing IDisposable
and IAsyncDisposable
with empty methods Dispose
/DisposeAsync
.
public IDisposable Method_1()
{
return Empty.Disposable();
}
public static IAsyncDisposable Method_2()
{
return Empty.AsyncDisposable();
}
Convenience methods providing empty collections like IEnumerable
, IReadOnlyList<T>
, IReadOnlyDictionary<TKey, TValue>
, ILookup<TKey, TValue>
and IReadOnlySet<T>
.
public static void Main()
{
Method_1(Empty.Collection());
Method_2(Empty.Collection<string>());
Method_3(Empty.Collection<int>());
Method_4(Empty.Collection<int>());
Method_5(Empty.Dictionary<string, int>());
Method_6(Empty.Lookup<string, int>());
Method_7(Empty.Set<string>());
}
public static void Method_1(IEnumerable collection)
{
}
public static void Method_2(IEnumerable<string> collection)
{
}
public static void Method_3(IReadOnlyCollection<int> collection)
{
}
public static void Method_4(IReadOnlyList<int> collection)
{
}
public static void Method_5(IReadOnlyDictionary<string, int> dictionary)
{
}
public static void Method_6(ILookup<string, int> lookup)
{
}
public static void Method_7(IReadOnlySet<string> set)
{
}