You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
757 B
C#
38 lines
757 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LogStudy.DiagnosticLog
|
|
{
|
|
/// <summary>
|
|
/// 观察者
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
public class Observer<T> : IObserver<T>
|
|
{
|
|
private readonly Action<T> _onNext;
|
|
|
|
public Observer(Action<T> onNext)
|
|
{
|
|
_onNext = onNext;
|
|
}
|
|
|
|
public void OnCompleted()
|
|
{
|
|
Console.WriteLine("完成");
|
|
}
|
|
|
|
public void OnError(Exception error)
|
|
{
|
|
Console.WriteLine($"出现异常:{error.Message}");
|
|
}
|
|
|
|
public void OnNext(T value)
|
|
{
|
|
_onNext(value);
|
|
}
|
|
}
|
|
}
|