I’m undecided

"Arguments.ToObject()" method doesnt work for "GUID" fields.

"Arguments.ToObject()" method doesnt work for "GUID" fields.
I am using "Arguments.ToObject<>()" method for converting page arguments into Data.Object. This method breaks while assigning Field of type "GUID". I have modified the code as below which is working for me. I am expecting this should be taken care in future updates.Please Fix this in future updates.

public void AssignTo(object instance)
{
CheckModified();
Type t = instance.GetType();
System.Reflection.PropertyInfo propInfo = t.GetProperty(Name);
object v = Value;
if (v != null)
if (propInfo.PropertyType.IsGenericType)
{
if (propInfo.PropertyType.GetProperty("Value").PropertyType.Name == "Guid")
{
v = new Guid(v.ToString());
}
else
{
v = Convert.ChangeType(v, propInfo.PropertyType.GetProperty("Value").PropertyType);
}
}
else
v = Convert.ChangeType(v, propInfo.PropertyType);
t.InvokeMember(Name, System.Reflection.BindingFlags.SetProperty, null, instance, new object[] {
v});
}
1 person has
this problem
+1
Reply