架构大更
This commit is contained in:
@@ -1,21 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System;
|
||||
|
||||
namespace UniRx
|
||||
{
|
||||
/// <summary>
|
||||
/// Notify boolean flag.
|
||||
/// Notify boolean flag.
|
||||
/// </summary>
|
||||
public class BooleanNotifier : IObservable<bool>
|
||||
{
|
||||
readonly Subject<bool> boolTrigger = new Subject<bool>();
|
||||
private readonly Subject<bool> boolTrigger = new();
|
||||
|
||||
private bool boolValue;
|
||||
|
||||
/// <summary>
|
||||
/// Setup initial flag.
|
||||
/// </summary>
|
||||
public BooleanNotifier(bool initialValue = false)
|
||||
{
|
||||
Value = initialValue;
|
||||
}
|
||||
|
||||
bool boolValue;
|
||||
/// <summary>Current flag value</summary>
|
||||
public bool Value
|
||||
{
|
||||
get { return boolValue; }
|
||||
get => boolValue;
|
||||
set
|
||||
{
|
||||
boolValue = value;
|
||||
@@ -23,51 +30,37 @@ namespace UniRx
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup initial flag.
|
||||
/// </summary>
|
||||
public BooleanNotifier(bool initialValue = false)
|
||||
{
|
||||
this.Value = initialValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set and raise true if current value isn't true.
|
||||
/// </summary>
|
||||
public void TurnOn()
|
||||
{
|
||||
if (Value != true)
|
||||
{
|
||||
Value = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set and raise false if current value isn't false.
|
||||
/// </summary>
|
||||
public void TurnOff()
|
||||
{
|
||||
if (Value != false)
|
||||
{
|
||||
Value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set and raise reverse value.
|
||||
/// </summary>
|
||||
public void SwitchValue()
|
||||
{
|
||||
Value = !Value;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Subscribe observer.
|
||||
/// Subscribe observer.
|
||||
/// </summary>
|
||||
public IDisposable Subscribe(IObserver<bool> observer)
|
||||
{
|
||||
return boolTrigger.Subscribe(observer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set and raise true if current value isn't true.
|
||||
/// </summary>
|
||||
public void TurnOn()
|
||||
{
|
||||
if (!Value) Value = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set and raise false if current value isn't false.
|
||||
/// </summary>
|
||||
public void TurnOff()
|
||||
{
|
||||
if (Value) Value = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set and raise reverse value.
|
||||
/// </summary>
|
||||
public void SwitchValue()
|
||||
{
|
||||
Value = !Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user