punish v6.8.18.0
This commit is contained in:
commit
cfb4dea47e
316 changed files with 554088 additions and 0 deletions
83
Questionable.Model/Questionable.Model.Questing/ExcelRef.cs
Normal file
83
Questionable.Model/Questionable.Model.Questing/ExcelRef.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
using System;
|
||||
|
||||
namespace Questionable.Model.Questing;
|
||||
|
||||
public class ExcelRef
|
||||
{
|
||||
public enum EType
|
||||
{
|
||||
None,
|
||||
Key,
|
||||
RowId,
|
||||
RawString
|
||||
}
|
||||
|
||||
private readonly string? _stringValue;
|
||||
|
||||
private readonly uint? _rowIdValue;
|
||||
|
||||
public EType Type { get; }
|
||||
|
||||
public ExcelRef(string value)
|
||||
{
|
||||
_stringValue = value;
|
||||
_rowIdValue = null;
|
||||
Type = EType.Key;
|
||||
}
|
||||
|
||||
public ExcelRef(uint value)
|
||||
{
|
||||
_stringValue = null;
|
||||
_rowIdValue = value;
|
||||
Type = EType.RowId;
|
||||
}
|
||||
|
||||
private ExcelRef(string? stringValue, uint? rowIdValue, EType type)
|
||||
{
|
||||
_stringValue = stringValue;
|
||||
_rowIdValue = rowIdValue;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public static ExcelRef FromKey(string value)
|
||||
{
|
||||
return new ExcelRef(value, null, EType.Key);
|
||||
}
|
||||
|
||||
public static ExcelRef FromRowId(uint rowId)
|
||||
{
|
||||
return new ExcelRef(null, rowId, EType.RowId);
|
||||
}
|
||||
|
||||
public static ExcelRef FromSheetValue(string value)
|
||||
{
|
||||
return new ExcelRef(value, null, EType.RawString);
|
||||
}
|
||||
|
||||
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 string AsRawString()
|
||||
{
|
||||
if (Type != EType.RawString)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
return _stringValue;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue