qamp/Qrakhen.Qamp.Core/Values/Objects/ItemProvider.cs

26 lines
762 B
C#

namespace Qrakhen.Qamp.Core.Values.Objects;
public abstract class ItemProvider<T>(ValueType type) : Obj(type)
{
public void Set(Value index, Value value)
{
T _index = ExtractIndex(index);
AssertValidAccesor(_index);
InnerSet(_index, value);
}
public Value Get(Value index)
{
T _index = ExtractIndex(index);
AssertValidAccesor(_index);
return InnerGet(_index);
}
protected abstract Value InnerGet(T index);
protected abstract void InnerSet(T index, Value value);
protected abstract void AssertValidAccesor(T index);
protected abstract T ExtractIndex(Value value);
}
public class ItemProviderException(string message, object context) : QampException(message, context);