整理代码
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace ShrlAlgo.RvKits.RvIndependent.MetroGauges.LandXMLData
|
||||
{
|
||||
[XmlType("Units")]
|
||||
[Serializable]
|
||||
public class Units
|
||||
{
|
||||
public Units()
|
||||
{
|
||||
units = new List<Unit>();
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public Unit this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < units.Count)
|
||||
{
|
||||
return units[index];
|
||||
}
|
||||
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index < units.Count)
|
||||
{
|
||||
units[index] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == units.Count)
|
||||
{
|
||||
units.Add(value);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public int Count => units.Count;
|
||||
|
||||
[XmlIgnore]
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
[XmlElement("Metric", Type = typeof(Metric))]
|
||||
[XmlElement("Imperial", Type = typeof(Imperial))]
|
||||
public List<Unit> units { get; set; }
|
||||
|
||||
public void Add(Unit item)
|
||||
{
|
||||
units.Add(item);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
units.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(Unit item)
|
||||
{
|
||||
return units.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(Unit[] array, int arrayIndex)
|
||||
{
|
||||
units.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public IEnumerator<Unit> GetEnumerator()
|
||||
{
|
||||
return units.GetEnumerator();
|
||||
}
|
||||
|
||||
public int IndexOf(Unit item)
|
||||
{
|
||||
return units.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, Unit item)
|
||||
{
|
||||
units.Insert(index, item);
|
||||
}
|
||||
|
||||
public bool Remove(Unit item)
|
||||
{
|
||||
return units.Remove(item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
units.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user