sockscape/server/Libraries/Glove/INI/Section.cs

36 lines
893 B
C#
Raw Normal View History

2017-06-06 21:13:25 +00:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2017-07-22 19:27:41 +00:00
namespace Glove.INI {
2017-06-07 21:02:29 +00:00
public class Section : IEnumerable<Instance> {
2017-08-21 21:03:32 +00:00
private readonly List<Instance> Instances = new List<Instance>();
2017-06-06 21:13:25 +00:00
2017-06-07 21:02:29 +00:00
internal Section() { }
internal Instance Push() {
Instances.Add(new Instance());
return Instances[Instances.Count - 1];
}
2017-08-21 21:03:32 +00:00
public string this[string key]
=> Instances[0][key];
2017-06-07 21:02:29 +00:00
2017-08-21 21:03:32 +00:00
public Instance this[int i]
=> Instances[i];
2017-06-07 21:02:29 +00:00
2017-08-21 21:03:32 +00:00
public int Count => Instances.Count;
2017-06-07 21:02:29 +00:00
IEnumerator IEnumerable.GetEnumerator() {
return Instances.GetEnumerator();
}
IEnumerator<Instance> IEnumerable<Instance>.GetEnumerator() {
2017-06-06 21:13:25 +00:00
return Instances.GetEnumerator();
}
}
}