Questionable/Questionable.Model/V1/ExcelRef.cs

49 lines
843 B
C#
Raw Permalink Normal View History

2024-06-12 16:03:48 +00:00
using System;
namespace Questionable.Model.V1;
public class ExcelRef
{
private readonly string? _stringValue;
private readonly uint? _rowIdValue;
public ExcelRef(string value)
{
_stringValue = value;
_rowIdValue = null;
Type = EType.Key;
}
public ExcelRef(uint value)
{
_stringValue = null;
_rowIdValue = value;
Type = EType.RowId;
}
public EType Type { get; }
public string AsKey()
{
if (Type != EType.Key)
throw new InvalidOperationException();
return _stringValue!;
}
public uint AsRowId()
{
if (Type != EType.RowId)
throw new InvalidOperationException();
return _rowIdValue!.Value;
}
public enum EType
{
None,
Key,
RowId,
}
}