Files
mixtape/zero.Core/Entities/Ref.cs
T

79 lines
1.6 KiB
C#
Raw Normal View History

2020-11-12 16:01:45 +01:00
namespace zero.Core.Entities
2020-09-17 16:10:21 +02:00
{
2020-11-12 16:01:45 +01:00
public class ValueRef<T> : ValueRef<T, string> where T : IZeroIdEntity
{
public ValueRef() : base() { }
public ValueRef(string id, string value) : base(id, value) { }
public static implicit operator string(ValueRef<T> reference) => reference.Id;
}
public class ValueRef<TEntity, TValue> : Ref where TEntity : IZeroIdEntity
{
public ValueRef() : base() { }
public ValueRef(string id, TValue value) : base(id)
{
Value = value;
}
public TValue Value { get; set; }
public static implicit operator string(ValueRef<TEntity, TValue> reference) => reference.Id;
}
//public class ValueRef : Ref
//{
// public ValueRef() : base() { }
// public ValueRef(string id, string value) : base(id)
// {
// Value = value;
// }
// public string Value { get; set; }
// public override string ToString()
// {
// return (Id, Value).ToString();
// }
//}
2020-09-18 01:06:21 +02:00
public class Ref<T> : Ref where T : IZeroIdEntity
{
public Ref() : base() { }
public Ref(string id) : base(id) { }
2020-11-12 16:01:45 +01:00
public static implicit operator Ref<T>(string id) => new Ref<T>(id);
public static implicit operator string(Ref<T> reference) => reference.Id;
2020-09-18 01:06:21 +02:00
}
public class Ref
2020-09-17 16:10:21 +02:00
{
public Ref() { }
public Ref(string id)
{
Id = id;
}
2020-09-18 01:06:21 +02:00
public string Id { get; set; }
2020-09-17 16:10:21 +02:00
public override string ToString()
{
return Id;
}
2020-11-12 16:01:45 +01:00
public static implicit operator Ref(string id) => new Ref(id);
public static implicit operator string(Ref reference) => reference.Id;
2020-09-17 16:10:21 +02:00
}
}