-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Action, Function and EventHandler (#116)
- Loading branch information
1 parent
d1fdb44
commit 9466adc
Showing
9 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project> | ||
<ItemGroup> | ||
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project> | ||
<ItemGroup> | ||
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// Portions Copyright (c) Microsoft Corporation. All rights reserved. | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
namespace System | ||
{ | ||
using System.Runtime.CompilerServices; | ||
|
||
/// <summary> | ||
/// Encapsulates a method that has no parameters and does not return a value. | ||
/// </summary> | ||
public delegate void Action(); | ||
|
||
/// <summary> | ||
/// Encapsulates a method that has a single parameter and does not return a value. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the parameter of the method that this delegate encapsulates. | ||
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam> | ||
/// <param name="obj">The parameter of the method that this delegate encapsulates.</param> | ||
public delegate void Action<in T>(T obj); | ||
|
||
/// <summary> | ||
/// Encapsulates a method that has a single parameter and does not return a value. | ||
/// </summary> | ||
/// <typeparam name="T1">The type of the first parameter of the method that this delegate encapsulates. | ||
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam> | ||
/// <typeparam name="T2">The type of the second parameter of the method that this delegate encapsulates. | ||
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam> | ||
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param> | ||
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param> | ||
public delegate void Action<in T1, in T2>(T1 arg1, T2 arg2); | ||
|
||
/// <summary> | ||
/// Encapsulates a method that has no parameters and returns a value of the type specified by the <typeparamref name="TResult"/> parameter. | ||
/// </summary> | ||
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates. | ||
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam> | ||
/// <returns>The return value of the method that this delegate encapsulates.</returns> | ||
public delegate TResult Func<out TResult>(); | ||
|
||
/// <summary> | ||
/// Encapsulates a method that has one parameter and returns a value of the type specified by the <typeparamref name="TResult"/> parameter. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the parameter of the method that this delegate encapsulates. | ||
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam> | ||
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates. | ||
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam> | ||
/// <param name="arg">The parameter of the method that this delegate encapsulates.</param> | ||
/// <returns>The return value of the method that this delegate encapsulates.</returns> | ||
public delegate TResult Func<in T, out TResult>(T arg); | ||
|
||
/// <summary> | ||
/// Encapsulates a method that has one parameter and returns a value of the type specified by the <typeparamref name="TResult"/> parameter. | ||
/// </summary> | ||
/// <typeparam name="T1">The type of the parameter of the method that this delegate encapsulates.</typeparam> | ||
/// <typeparam name="T2">The type of the parameter of the method that this delegate encapsulates.</typeparam> | ||
/// <typeparam name="TResult">The type of the return value of the method that this delegate encapsulates. | ||
/// This type parameter is covariant.That is, you can use either the type you specified or any type that is more derived.For more information about covariance and contravariance, see <see href="https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance">Covariance and Contravariance in Generics</see>.</typeparam> | ||
/// <param name="arg1">The first parameter of the method that this delegate encapsulates.</param> | ||
/// <param name="arg2">The second parameter of the method that this delegate encapsulates.</param> | ||
/// <returns>The return value of the method that this delegate encapsulates.</returns> | ||
public delegate TResult Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// Portions Copyright (c) Microsoft Corporation. All rights reserved. | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
namespace System | ||
{ | ||
/// <summary> | ||
/// Represents the base class for classes that contain event data, and provides a value to use for events that do not include event data. | ||
/// </summary> | ||
public class EventArgs | ||
{ | ||
/// <summary> | ||
/// Provides a value to use with events that do not have event data. | ||
/// </summary> | ||
public static readonly EventArgs Empty = new EventArgs(); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="EventArgs"/> class. | ||
/// </summary> | ||
public EventArgs() | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// Portions Copyright (c) Microsoft Corporation. All rights reserved. | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
namespace System | ||
{ | ||
/// <summary> | ||
/// Represents the method that will handle an event that has no event data. | ||
/// </summary> | ||
/// <param name="sender">The source of the event.</param> | ||
/// <param name="e">An object that contains no event data.</param> | ||
public delegate void EventHandler(object sender, EventArgs e); | ||
|
||
/// <summary> | ||
/// Represents the method that will handle an event when the event provides data. | ||
/// </summary> | ||
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam> | ||
/// <param name="sender">The source of the event.</param> | ||
/// <param name="e">An object that contains the event data.</param> | ||
#pragma warning disable S3246 // This is nanoFramework implementation of the EventHandler. It's meant to be this way. | ||
public delegate void EventHandler<TEventArgs>(object sender, TEventArgs e); | ||
#pragma warning restore S3246 // Generic type parameters should be co/contravariant when possible | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters