HamBook – Rev 54
?pathlinks?
using System;
namespace HamBook.Radios.Generic
{
public class RadioStorage
{
public RadioStorage(string storage)
{
Storage = Parse(storage);
}
public RadioStorage(int storage)
{
Storage = Parse(storage);
}
public int Storage { get; }
public static bool TryParse(string storage, out RadioStorage radioMode)
{
switch (storage)
{
case "VFO":
case "Memory":
case "Memory Tune":
case "PMS":
radioMode = new RadioStorage(storage);
return true;
default:
radioMode = null;
return false;
}
}
public static bool TryParse(int storage, out RadioStorage radioMode)
{
switch (storage)
{
case 0:
case 1:
case 2:
case 5:
radioMode = new RadioStorage(storage);
return true;
default:
radioMode = null;
return false;
}
}
private int Parse(string storage)
{
switch (storage)
{
case "VFO":
return 0;
case "Memory":
return 1;
case "Memory Tune":
return 2;
case "PMS":
return 5;
default:
throw new ArgumentException();
}
}
private int Parse(int storage)
{
switch (storage)
{
case 0:
case 1:
case 2:
case 5:
return storage;
default:
throw new ArgumentException();
}
}
public static implicit operator RadioStorage(string storage)
{
return new RadioStorage(storage);
}
public static implicit operator string(RadioStorage radioStorage)
{
switch (radioStorage.Storage)
{
case 0:
return "VFO";
case 1:
return "Memory";
case 2:
return "Memory Tune";
case 5:
return "PMS";
default:
throw new ArgumentException();
}
}
public static implicit operator RadioStorage(int storage)
{
return new RadioStorage(storage);
}
public static implicit operator int(RadioStorage radioMode)
{
return radioMode.Storage;
}
}
}
Generated by GNU Enscript 1.6.5.90.