2016-12-31 13:56:10 +01:00
|
|
|
|
using System;
|
2016-11-12 17:02:48 +01:00
|
|
|
|
using System.Collections;
|
2016-12-31 13:56:10 +01:00
|
|
|
|
using System.Collections.Generic;
|
2016-11-12 17:02:48 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace SonicAudioLib.CriMw
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
internal class CriRowRecord
|
|
|
|
|
{
|
|
|
|
|
public CriField Field { get; set; }
|
|
|
|
|
public object Value { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 17:02:48 +01:00
|
|
|
|
public class CriRow : IEnumerable
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
private List<CriRowRecord> records = new List<CriRowRecord>();
|
2016-11-12 17:02:48 +01:00
|
|
|
|
private CriTable parent;
|
|
|
|
|
|
|
|
|
|
public object this[CriField criField]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
return this[records.FindIndex(record => record.Field == criField)];
|
2016-11-12 17:02:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
this[records.FindIndex(record => record.Field == criField)] = value;
|
2016-11-12 17:02:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object this[int index]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
if (index < 0 || index >= records.Count)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return records[index].Value;
|
2016-11-12 17:02:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
if (index < 0 || index >= records.Count)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
records[index].Value = value;
|
2016-11-12 17:02:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object this[string name]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
return this[records.FindIndex(record => record.Field.FieldName == name)];
|
2016-11-12 17:02:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
this[records.FindIndex(record => record.Field.FieldName == name)] = value;
|
2016-11-12 17:02:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CriTable Parent
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal set
|
|
|
|
|
{
|
|
|
|
|
parent = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-31 13:56:10 +01:00
|
|
|
|
internal List<CriRowRecord> Records
|
2016-11-12 17:02:48 +01:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return records;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int FieldCount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return records.Count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-21 00:19:47 +02:00
|
|
|
|
public T GetValue<T>(CriField criField)
|
|
|
|
|
{
|
|
|
|
|
return (T)this[criField];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T GetValue<T>(string fieldName)
|
|
|
|
|
{
|
|
|
|
|
return (T)this[fieldName];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T GetValue<T>(int fieldIndex)
|
|
|
|
|
{
|
|
|
|
|
return (T)this[fieldIndex];
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 17:02:48 +01:00
|
|
|
|
public object[] GetValueArray()
|
|
|
|
|
{
|
|
|
|
|
object[] values = new object[records.Count];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < records.Count; i++)
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
values[i] = records[i].Value;
|
2016-11-12 17:02:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerator GetEnumerator()
|
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
foreach (var record in records)
|
2016-11-12 17:02:48 +01:00
|
|
|
|
{
|
2016-12-31 13:56:10 +01:00
|
|
|
|
yield return record.Value;
|
2016-11-12 17:02:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal CriRow(CriTable parent)
|
|
|
|
|
{
|
|
|
|
|
this.parent = parent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|