331 lines
8.6 KiB
C#
331 lines
8.6 KiB
C#
|
|
using System.Text;
|
|||
|
|
|
|||
|
|
namespace DatabaseImport
|
|||
|
|
{
|
|||
|
|
public class IsoCode
|
|||
|
|
{
|
|||
|
|
private char[] _isoCodeFull = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' };
|
|||
|
|
|
|||
|
|
private char _TestObject
|
|||
|
|
{
|
|||
|
|
get => _isoCodeFull[0];
|
|||
|
|
set => _isoCodeFull[0] = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string TestObject
|
|||
|
|
{
|
|||
|
|
get => new string(new[] { _TestObject });
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(value))
|
|||
|
|
{
|
|||
|
|
_TestObject = '?';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_TestObject = value[0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private char _Position
|
|||
|
|
{
|
|||
|
|
get => _isoCodeFull[1];
|
|||
|
|
set => _isoCodeFull[1] = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string Position
|
|||
|
|
{
|
|||
|
|
get => new string(new[] { _Position });
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(value))
|
|||
|
|
{
|
|||
|
|
_Position = '?';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_Position = value[0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private char[] _MainLocation
|
|||
|
|
{
|
|||
|
|
get => new[] { _isoCodeFull[2], _isoCodeFull[3], _isoCodeFull[4], _isoCodeFull[5] };
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
for (var i = 0; i < 4; i++)
|
|||
|
|
{
|
|||
|
|
if (value.Length <= i)
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 2] = '0';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 2] = value[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string MainLocation
|
|||
|
|
{
|
|||
|
|
get => new string(_MainLocation);
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
var main = value;
|
|||
|
|
if (main.Length < 4)
|
|||
|
|
{
|
|||
|
|
main = main.PadRight(4, '?');
|
|||
|
|
}
|
|||
|
|
else if (main.Length > 4)
|
|||
|
|
{
|
|||
|
|
main = main.Substring(0, 4);
|
|||
|
|
}
|
|||
|
|
_MainLocation = main.ToCharArray(0, 4);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private char[] _FineLocation1
|
|||
|
|
{
|
|||
|
|
get => new[] { _isoCodeFull[6], _isoCodeFull[7] };
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
for (var i = 0; i < 2; i++)
|
|||
|
|
{
|
|||
|
|
if (value.Length < i)
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 6] = '0';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 6] = value[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string FineLocation1
|
|||
|
|
{
|
|||
|
|
get => new string(_FineLocation1);
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
var loc = value;
|
|||
|
|
if (loc.Length < 2)
|
|||
|
|
{
|
|||
|
|
loc = loc.PadRight(2, '?');
|
|||
|
|
}
|
|||
|
|
else if (loc.Length > 2)
|
|||
|
|
{
|
|||
|
|
loc = loc.Substring(0, 2);
|
|||
|
|
}
|
|||
|
|
_FineLocation1 = loc.ToCharArray(0, 2);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private char[] _FineLocation2
|
|||
|
|
{
|
|||
|
|
get => new[] { _isoCodeFull[8], _isoCodeFull[9] };
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
for (var i = 0; i < 2; i++)
|
|||
|
|
{
|
|||
|
|
if (value.Length < i)
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 8] = '0';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 8] = value[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string FineLocation2
|
|||
|
|
{
|
|||
|
|
get => new string(_FineLocation2);
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
var loc = value;
|
|||
|
|
if (loc.Length < 2)
|
|||
|
|
{
|
|||
|
|
loc = loc.PadRight(2, '?');
|
|||
|
|
}
|
|||
|
|
else if (loc.Length > 2)
|
|||
|
|
{
|
|||
|
|
loc = loc.Substring(0, 2);
|
|||
|
|
}
|
|||
|
|
_FineLocation2 = loc.ToCharArray(0, 2);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private char[] _FineLocations3
|
|||
|
|
{
|
|||
|
|
get => new[] { _isoCodeFull[10], _isoCodeFull[11] };
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
for (var i = 0; i < 2; i++)
|
|||
|
|
{
|
|||
|
|
if (value.Length < i)
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 10] = '0';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 10] = value[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string FineLocation3
|
|||
|
|
{
|
|||
|
|
get => new string(_FineLocations3);
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
var loc = value;
|
|||
|
|
if (loc.Length < 2)
|
|||
|
|
{
|
|||
|
|
loc = loc.PadRight(2, '?');
|
|||
|
|
}
|
|||
|
|
else if (loc.Length > 2)
|
|||
|
|
{
|
|||
|
|
loc = loc.Substring(0, 2);
|
|||
|
|
}
|
|||
|
|
_FineLocations3 = loc.ToCharArray(0, 2);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private char[] _PhysicalDimension
|
|||
|
|
{
|
|||
|
|
get => new[] { _isoCodeFull[12], _isoCodeFull[13] };
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
for (var i = 0; i < 2; i++)
|
|||
|
|
{
|
|||
|
|
if (value.Length < i)
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 12] = '0';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i + 12] = value[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string PhysicalDimension
|
|||
|
|
{
|
|||
|
|
get => new string(_PhysicalDimension);
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
var dim = value;
|
|||
|
|
if (dim.Length < 2)
|
|||
|
|
{
|
|||
|
|
dim = dim.PadRight(2, '?');
|
|||
|
|
}
|
|||
|
|
else if (dim.Length > 2)
|
|||
|
|
{
|
|||
|
|
dim = dim.Substring(0, 2);
|
|||
|
|
}
|
|||
|
|
_PhysicalDimension = dim.ToCharArray(0, 2);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private char _Direction
|
|||
|
|
{
|
|||
|
|
get => _isoCodeFull[14];
|
|||
|
|
set => _isoCodeFull[14] = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string Direction
|
|||
|
|
{
|
|||
|
|
get => new string(new[] { _Direction });
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(value))
|
|||
|
|
{
|
|||
|
|
_Direction = '?';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_Direction = value[0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private char _FilterClass
|
|||
|
|
{
|
|||
|
|
get => _isoCodeFull[15];
|
|||
|
|
set => _isoCodeFull[15] = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string FilterClass
|
|||
|
|
{
|
|||
|
|
get => new string(new[] { _FilterClass });
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(value))
|
|||
|
|
{
|
|||
|
|
_FilterClass = '?';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_FilterClass = value[0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public IsoCode(string isoCode)
|
|||
|
|
{
|
|||
|
|
if (null == isoCode)
|
|||
|
|
{
|
|||
|
|
isoCode = "";
|
|||
|
|
}
|
|||
|
|
if (isoCode.Length > 16)
|
|||
|
|
{
|
|||
|
|
isoCode = isoCode.Substring(0, 16);
|
|||
|
|
}
|
|||
|
|
if (isoCode.Length < 16)
|
|||
|
|
{
|
|||
|
|
isoCode = isoCode.PadRight(16, '?');
|
|||
|
|
}
|
|||
|
|
for (var i = 0; i < 16; i++)
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i] = isoCode[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string StringRepresentation
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
var sb = new StringBuilder();
|
|||
|
|
foreach (var c in _isoCodeFull)
|
|||
|
|
{
|
|||
|
|
sb.Append(c);
|
|||
|
|
}
|
|||
|
|
return sb.ToString();
|
|||
|
|
}
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
for (var i = 0; i < 16; i++)
|
|||
|
|
{
|
|||
|
|
if (i >= value.Length)
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i] = '0';
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_isoCodeFull[i] = value[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|