
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 0.78 KB | hits: 12 | expires: Never
System.Dynamic ExpandoControl is it possible?
<x:ExpandoControl someProperty="a value"></x:ExpandoControl>
public interface IAttributeAccessor
{
string GetAttribute(string key);
void SetAttribute(string key, string value);
}
public class ExpandoControl : Control, IAttributeAccessor
{
IDictionary<string, object> _expando = new ExpandoObject();
public dynamic Expando
{
{
return _expando;
}
}
void IAttributeAccessor.SetValue(string key, string value)
{
_expando[key] = value;
}
string IAttributeAccessor.GetValue(string key)
{
object value;
if (_expando.TryGetValue(key, out value) && value != null)
return value.ToString();
else
return null;
}
}