56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace BCG
|
|
{
|
|
public class CaseChangeStream : ViewStream, IStreamMapper
|
|
{
|
|
|
|
private string[] myCaseChangingColumns;
|
|
bool myIsUpperCase;
|
|
|
|
public CaseChangeStream(ViewStream input, bool toUpper, params string[] columnsToChangeCase)
|
|
{
|
|
myCaseChangingColumns = columnsToChangeCase;
|
|
mySetRealSource(new SuperMapStream(input, this));
|
|
myIsUpperCase = toUpper;
|
|
}
|
|
|
|
|
|
|
|
|
|
#region IStreamMapper Members
|
|
|
|
public IBlueTableSchema getOutputSchema(IBlueTableSchema inputSchema)
|
|
{
|
|
return inputSchema;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IDynamicStreamMapper Members
|
|
|
|
public IBlueRow map(IBlueRow row)
|
|
{
|
|
object[] outValues = new object[row.Count];
|
|
|
|
row.CopyTo(outValues,0);
|
|
|
|
foreach (string colName in myCaseChangingColumns)
|
|
{
|
|
ColumnInfo thisCol = row.schema[colName];
|
|
object rowVal = outValues[thisCol.colNo];
|
|
|
|
if (rowVal is string && !string.IsNullOrEmpty((string)rowVal))
|
|
outValues[thisCol.colNo] = myIsUpperCase ? ((string)rowVal).ToUpper() : ((string)rowVal).ToLower();
|
|
}
|
|
|
|
return new BlueRow(row.schema, outValues);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|