-
-
Save acple/f16b086c837deae523c3 to your computer and use it in GitHub Desktop.
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
using System; | |
namespace ReactiveExtensionsTest | |
{ | |
class Program | |
{ | |
public static void Main() | |
{ | |
var test = new イベント受け取るテスト(); | |
test.Start(); | |
Console.ReadKey(true); | |
} | |
} | |
public class イベント受け取るテスト | |
{ | |
public void Start() | |
{ | |
var i = 1; // ichi | |
var eventTest = new 発行する側クラス<int>(); | |
eventTest.イベント本体 += this.イベント受け取るやつ; | |
eventTest.イベント発火するやつ(i); | |
} | |
public void イベント受け取るやつ(int value) | |
{ | |
Console.WriteLine($"Eventきたぞ!値は{ value }だぞ!"); | |
} | |
} | |
public class 発行する側クラス<T> | |
{ | |
public event Action<T> イベント本体; | |
public void イベント発火するやつ(T value) | |
{ | |
if (this.イベント本体 != null) | |
{ | |
Console.WriteLine($"今から{ value }を送出するぞ!"); | |
イベント本体(value); | |
Console.WriteLine($"{ value }を送出したぞ!"); | |
} | |
} | |
} | |
/*/ 実行結果 | |
今から1を送出するぞ! | |
Eventきたぞ!値は1だぞ! | |
1を送出したぞ! | |
/*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment