44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
namespace BITKit
|
|||
|
{
|
|||
|
public interface IReference
|
|||
|
{
|
|||
|
string Get();
|
|||
|
}
|
|||
|
public interface IReference<T>
|
|||
|
{
|
|||
|
T Get();
|
|||
|
}
|
|||
|
[System.Serializable]
|
|||
|
public abstract record References : IReference
|
|||
|
{
|
|||
|
public abstract string Get();
|
|||
|
public static implicit operator string(References self) => self.Get();
|
|||
|
public override string ToString() => Get();
|
|||
|
}
|
|||
|
[System.Serializable]
|
|||
|
public abstract record References<T> : IReference<T>
|
|||
|
{
|
|||
|
public abstract T Get();
|
|||
|
public static implicit operator T(References<T> self) => self.Get();
|
|||
|
}
|
|||
|
[System.Serializable]
|
|||
|
public record Reference : References
|
|||
|
{
|
|||
|
public Reference() { }
|
|||
|
public Reference(string value)
|
|||
|
{
|
|||
|
this.value = value;
|
|||
|
}
|
|||
|
|
|||
|
public string value;
|
|||
|
public override string Get() => value;
|
|||
|
}
|
|||
|
[System.Serializable]
|
|||
|
public record Reference<T> : References<T>
|
|||
|
{
|
|||
|
public T value;
|
|||
|
public override T Get() => value;
|
|||
|
}
|
|||
|
}
|