InstanceDescriptor GetDefaultInstanceDescriptor (object value)
{
if (value is System.Web.UI.WebControls.Unit) {
System.Web.UI.WebControls.Unit s = (System.Web.UI.WebControls.Unit) value;
if (s.IsEmpty) {
FieldInfo f = typeof (Unit).GetField ("Empty");
return new InstanceDescriptor (f, null);
}
ConstructorInfo c = typeof(System.Web.UI.WebControls.Unit).GetConstructor (
BindingFlags.Instance | BindingFlags.Public,
null,
new Type[] {typeof(double), typeof(System.Web.UI.WebControls.UnitType)},
null);
return new InstanceDescriptor (c, new object[] {s.Value, s.Type});
}
if (value is System.Web.UI.WebControls.FontUnit) {
System.Web.UI.WebControls.FontUnit s = (System.Web.UI.WebControls.FontUnit) value;
if (s.IsEmpty) {
FieldInfo f = typeof (FontUnit).GetField ("Empty");
return new InstanceDescriptor (f, null);
}
Type cParamType = null;
object cParam = null;
switch (s.Type) {
case FontSize.AsUnit:
case FontSize.NotSet:
cParamType = typeof (System.Web.UI.WebControls.Unit);
cParam = s.Unit;
break;
default:
cParamType = typeof (string);
cParam = s.Type.ToString ();
break;
}
ConstructorInfo c = typeof(System.Web.UI.WebControls.FontUnit).GetConstructor (
BindingFlags.Instance | BindingFlags.Public,
null,
new Type[] {cParamType},
null);
if (c != null)
return new InstanceDescriptor (c, new object[] {cParam});
}
return null;
}