public void MoveRaw(int rowIndexFrom, int rowIndexTo) { if (this.RowLength <= rowIndexFrom || rowIndexFrom < 0) { CsvGeneric.FromToIndexOutOfException(rowIndexFrom, false, true); return; } if (this.RowLength <= rowIndexTo || rowIndexTo < 0) { CsvGeneric.FromToIndexOutOfException(rowIndexTo, true, true); return; } if (rowIndexFrom == rowIndexTo) { return; } List <CsvValue> list = new List <CsvValue>(); for (int i = 0; i < this.ColumnLength; i++) { list.Add(this[i, rowIndexFrom]); this._value[i].value.RemoveAt(rowIndexFrom); } for (int j = 0; j < this.ColumnLength; j++) { this._value[j].value.Insert(rowIndexTo, list[j]); } }
public CsvValue this[int columnIndex, int rowIndex] { get { if (columnIndex < 0 || columnIndex >= this.ColumnLength) { CsvGeneric.IndexOutOfException(columnIndex, rowIndex); return(new CsvValue()); } if (rowIndex < 0 || rowIndex >= this.RowLength) { CsvGeneric.IndexOutOfException(columnIndex, rowIndex); return(new CsvValue()); } return(this._value[columnIndex].value[rowIndex]); } set { if (columnIndex < 0 || columnIndex >= this.ColumnLength) { CsvGeneric.IndexOutOfException(columnIndex, rowIndex); return; } if (rowIndex < 0 || rowIndex >= this.RowLength) { CsvGeneric.IndexOutOfException(columnIndex, rowIndex); return; } this._value[columnIndex].value[rowIndex] = value; } }
public static Csv Import(string path) { StreamReader streamReader = null; Csv result = null; try { if (!File.Exists(path)) { CsvGeneric.NotFoundFileException(path); return(null); } streamReader = new StreamReader(path); string text = streamReader.ReadToEnd(); text = text.Trim(new char[] { '\n', ' ' }); result = new Csv(text); } finally { if (streamReader != null) { streamReader.Close(); } } return(result); }
public void MoveColumn(int columnIndexFrom, int columnIndexTo) { if (this.ColumnLength <= columnIndexFrom || columnIndexFrom < 0) { CsvGeneric.FromToIndexOutOfException(columnIndexFrom, false, false); return; } if (this.ColumnLength <= columnIndexTo || columnIndexTo < 0) { CsvGeneric.FromToIndexOutOfException(columnIndexTo, true, false); return; } if (columnIndexFrom == columnIndexTo) { return; } string item = this._key[columnIndexFrom]; List <CsvValue> value = this._value[columnIndexFrom].value; this._key.RemoveAt(columnIndexFrom); this._value.RemoveAt(columnIndexFrom); this._key.Insert(columnIndexTo, item); CsvColumnList csvColumnList = new CsvColumnList(); csvColumnList.value = value; this._value.Insert(columnIndexTo, csvColumnList); }
public void Parse(TextAsset textAsset) { if (textAsset == null) { CsvGeneric.NullReferenceException(); return; } this.Parse(textAsset.text); }
public CsvRow GetRow(int rowIndex) { if (rowIndex < 0 || rowIndex >= this.RowLength) { CsvGeneric.IndexOutOfException(rowIndex, true); return(null); } return(new CsvRow(this._key.ToArray(), this.GetRowList(rowIndex).ToArray())); }
public string GetKey(int index) { if (index < 0 || index >= this._key.Length) { CsvGeneric.IndexOutOfException(index, false); return(null); } return(this._key[index]); }
public void RemoveAt(int index) { if (this._raw.Count >= index || index < 0) { CsvGeneric.IndexOutOfException(index, false); return; } this._raw.RemoveAt(index); }
public void SetKey(int index, string key) { if (index < 0 || index >= this._key.Length) { CsvGeneric.IndexOutOfException(index, false); return; } this._key[index] = key; }
public void RemoveAtColumn(int columnIndex) { if (columnIndex >= this.ColumnLength || columnIndex < 0) { CsvGeneric.IndexOutOfException(columnIndex, false); return; } this._value.RemoveAt(columnIndex); }
public CsvColumn GetColumn(int columnIndex) { if (columnIndex < 0 || columnIndex >= this.ColumnLength) { CsvGeneric.IndexOutOfException(columnIndex, false); return(null); } return(new CsvColumn(this._key[columnIndex], this.GetColumnList(columnIndex).ToArray())); }
public void AddRow(CsvRow csvRow) { if (!this.CheckMachKey(csvRow)) { CsvGeneric.KeyNotMachingException(); return; } this.AddRow(); this.SetRow(this.RowLength - 1, csvRow); }
public void RemoveRow(CsvRow csvRow) { if (!this.ContainsRow(csvRow)) { CsvGeneric.RowNotFoundException(csvRow); return; } int rowIndex = this.RowIndexOf(csvRow); this.RemoveAtRow(rowIndex); }
public void ReplaceKey(string currentKey, string replaceKey) { int num = this.KeyToIndex(currentKey); if (num == -1) { CsvGeneric.KeyNotFoundException(currentKey); return; } this._key[num] = replaceKey; }
public void RemoveColumn(string column) { int num = this.KeyToIndex(column); if (num == -1) { CsvGeneric.KeyNotFoundException(column); return; } this._value.RemoveAt(num); }
public CsvColumn GetColumn(string column) { int num = this.IndexOfColumn(column); if (num == -1) { CsvGeneric.KeyNotFoundException(column); return(null); } return(this.GetColumn(num)); }
public void SetRow(int rowIndex, CsvRow csvRow) { if (this.RowLength <= rowIndex || rowIndex < 0) { CsvGeneric.IndexOutOfException(rowIndex, true); return; } for (int i = 0; i < this.ColumnLength; i++) { this[i, rowIndex] = csvRow[i]; } }
public void RemoveAtRow(int rowIndex) { for (int i = 0; i < this.ColumnLength; i++) { if (this.RowLength <= rowIndex || rowIndex < 0) { CsvGeneric.IndexOutOfException(rowIndex, true); return; } this._value[i].value.RemoveAt(rowIndex); } this._rowLengthCache--; }
public static CsvValue operator /(CsvValue a, double d) { double num; if (double.TryParse(a._value, out num)) { a.doubleValue = num / d; } else { CsvGeneric.NotDoubleValueException(a._value); } return(a); }
public static CsvValue operator /(CsvValue a, float i) { float num; if (float.TryParse(a._value, out num)) { a.floatValue = num / i; } else { CsvGeneric.NotFloatValueException(a._value); } return(a); }
public void AddColumn(string column) { if (this.KeyToIndex(column) != -1) { CsvGeneric.KeyOverlapException(column); return; } this._key.Add(column); this._value.Add(new CsvColumnList()); for (int i = 0; i < this.RowLength; i++) { this._value[this.ColumnLength - 1].value.Add(new CsvValue()); } }
public static CsvValue operator /(CsvValue a, int i) { int num; if (int.TryParse(a._value, out num)) { a.intValue = num / i; } else { CsvGeneric.NotIntValueException(a._value); } return(a); }
public void InsertRaw(int rowIndex, CsvRow csvRow) { if (this.RowLength < rowIndex || rowIndex < 0) { CsvGeneric.IndexOutOfException(rowIndex, true); return; } if (rowIndex == this.RowLength) { this.AddRow(csvRow); return; } for (int i = 0; i < this.ColumnLength; i++) { this._value[i].value.Insert(rowIndex, new CsvValue()); this[csvRow.GetKey(i), rowIndex] = csvRow[i]; } }
public CsvValue this[int columnIndex] { get { if (columnIndex < 0 || columnIndex >= this._key.Length) { CsvGeneric.IndexOutOfException(columnIndex, false); return(null); } return(this._column[columnIndex]); } set { if (columnIndex < 0 || columnIndex >= this._key.Length) { CsvGeneric.IndexOutOfException(columnIndex, false); return; } this._column[columnIndex] = value; } }
public CsvValue this[int row] { get { if (row < 0 || row >= this.Length) { CsvGeneric.IndexOutOfException(row, true); return(new CsvValue()); } return(this._raw[row]); } set { if (row < 0 || row >= this.Length) { CsvGeneric.IndexOutOfException(row, true); return; } this._raw[row] = value; } }
public CsvValue this[string key] { get { int num = this.KeyToIndex(key); if (num == -1) { CsvGeneric.KeyNotFoundException(key); return(new CsvValue()); } return(this[num]); } set { int num = this.KeyToIndex(key); if (num == -1) { CsvGeneric.KeyNotFoundException(key); return; } this[num] = value; } }
public CsvValue this[string columnKey, int rowIndex] { get { int num = this.KeyToIndex(columnKey); if (num == -1) { CsvGeneric.KeyNotFoundException(columnKey); return(new CsvValue()); } return(this[num, rowIndex]); } set { int num = this.KeyToIndex(columnKey); if (num == -1) { CsvGeneric.KeyNotFoundException(columnKey); return; } this[num, rowIndex] = value; } }
public void InsertColumn(int columnIndex, CsvColumn csvColumn) { if (columnIndex < 0 || columnIndex > this.ColumnLength) { CsvGeneric.IndexOutOfException(columnIndex, false); return; } List <CsvValue> list = this.CsvColumnToList(csvColumn); if (this.RowLength != list.Count) { while (this.RowLength != list.Count) { if (this.RowLength > list.Count) { list.Add(new CsvValue()); } else { this.AddRow(); } } } CsvColumnList csvColumnList = new CsvColumnList(); csvColumnList.value = this.CsvColumnToList(csvColumn); if (!this.ContainsColumn(csvColumn, false)) { this._key.Insert(columnIndex, csvColumn.key); this._value.Insert(columnIndex, csvColumnList); } else { this._key.Add(csvColumn.key); this._value.Add(csvColumnList); } }
public int RowIndexOf(CsvRow csvRow) { if (!this.CheckMachKey(csvRow)) { CsvGeneric.KeyNotMachingException(); return(-1); } for (int i = 0; i < this.ColumnLength; i++) { bool flag = true; for (int j = 0; j < this.RowLength; j++) { if (this[i, j] != csvRow[i]) { flag = false; } } if (flag) { return(i); } } return(-1); }