119 lines
3.1 KiB
C#
119 lines
3.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
|
|
namespace BCG
|
|
{
|
|
public class ChangeTableNameStream : ViewStream, IStreamMapper
|
|
{
|
|
private class MyRow : IBlueRow
|
|
{
|
|
private IBlueRow myRow;
|
|
private IBlueTableSchema mySchema;
|
|
internal MyRow (IBlueTableSchema s, IBlueRow r)
|
|
{
|
|
mySchema = s;
|
|
myRow = r;
|
|
}
|
|
|
|
#region IBlueRow Members
|
|
|
|
public IBlueTableSchema schema { get { return mySchema; } }
|
|
|
|
public object? this[int index] { get { return myRow[index]; } }
|
|
|
|
public object? this[string colName] { get { return myRow[colName]; } }
|
|
|
|
#endregion
|
|
|
|
#region IDictionary Members
|
|
|
|
public void Add(object key, object? value)
|
|
{
|
|
throw new Exception("The method or operation is not implemented.");
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
throw new Exception("The method or operation is not implemented.");
|
|
}
|
|
|
|
public bool Contains(object key) { return myRow.Contains(key); }
|
|
|
|
public IDictionaryEnumerator GetEnumerator() { return myRow.GetEnumerator(); }
|
|
|
|
public bool IsFixedSize { get { return true; } }
|
|
|
|
public bool IsReadOnly { get { return true; } }
|
|
|
|
public ICollection Keys { get { return myRow.Keys; } }
|
|
|
|
public void Remove(object key)
|
|
{
|
|
throw new Exception("The method or operation is not implemented.");
|
|
}
|
|
|
|
public ICollection Values { get { return myRow.Values; } }
|
|
|
|
public object? this[object key]
|
|
{
|
|
get { return myRow[key]; }
|
|
set { throw new Exception("The method or operation is not implemented."); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ICollection Members
|
|
|
|
public void CopyTo(Array array, int index) { myRow.CopyTo(array, index); }
|
|
|
|
public int Count { get { return myRow.Count; } }
|
|
|
|
public bool IsSynchronized { get { return myRow.IsSynchronized; } }
|
|
|
|
public object SyncRoot { get { return myRow.SyncRoot; } }
|
|
|
|
#endregion
|
|
|
|
#region IEnumerable Members
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() { return myRow.GetEnumerator(); }
|
|
|
|
#endregion
|
|
}
|
|
|
|
private string myNewName;
|
|
IBlueTableSchema? mySchema;
|
|
|
|
public ChangeTableNameStream (ViewStream vs, string name)
|
|
{
|
|
myNewName = name;
|
|
mySetRealSource (new MapStream (vs, this));
|
|
}
|
|
|
|
#region IStreamMapper Members
|
|
|
|
public IBlueTableSchema getOutputSchema (IBlueTableSchema inputSchema)
|
|
{
|
|
if (mySchema == null)
|
|
{
|
|
ArrayList cis = new ArrayList ();
|
|
foreach (ColumnInfo ci in inputSchema.columnInfo)
|
|
cis.Add (new ColumnInfo (ci.colName, ci.colNo, ci.colType));
|
|
mySchema = new BlueTableSchema (myNewName, cis.ToArray (typeof(ColumnInfo)) as ColumnInfo[]);
|
|
}
|
|
return mySchema;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IDynamicStreamMapper Members
|
|
|
|
public IBlueRow map (IBlueRow row)
|
|
{
|
|
return new MyRow (getOutputSchema (row.schema), row);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|