using System;
using System.Collections.Generic;
using System.Text;
using Ubik.Engine.Client;
namespace StoresAndStockPricing.Controls{
public class StringColumn<T> : BoundDataGridViewColumn<T>
where T : Individual
{
public delegate string GetColumnValueDelegate(Session session, T t);
private GetColumnValueDelegate _getColumnValueDelegate;
public delegate void SetColumnValueDelegate(Session session, T t, string value);
private SetColumnValueDelegate _setColumnValueDelegate;
public StringColumn(Session session, string name, GetColumnValueDelegate getColumnValueDelegate)
: this(session, name, getColumnValueDelegate, null)
{
}
public StringColumn(
Session session,
string name,
GetColumnValueDelegate getColumnValueDelegate,
SetColumnValueDelegate setColumnValueDelegate)
: base(session, name)
{
if (getColumnValueDelegate == null)
throw new ArgumentNullException("getColumnValueDelegate");
_getColumnValueDelegate = getColumnValueDelegate;
_setColumnValueDelegate = setColumnValueDelegate;
}
#region IBoundDataGridViewColumn<T> Members
protected override object GetColumnValue(Session session, T t)
{
return _getColumnValueDelegate(session, t);
}
protected override void SetColumnValue(Session session, T t, object value)
{
if (_setColumnValueDelegate == null)
throw new InvalidOperationException();
_setColumnValueDelegate(session, t, (string)value);
}
public override Type PropertyType
{
get
{
return typeof(string);
}
}
public override bool IsReadOnly
{
get
{
return _setColumnValueDelegate == null;
}
}
#endregion
}
}
|