// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
+using System.Linq.Expressions;
namespace Crow
{
handler(sender, e);
}
}
+ /// <summary>
+ /// Type Extension method for Casting
+ /// </summary>
+ public static object Cast(this Type Type, object data)
+ {
+ var DataParam = Expression.Parameter(typeof(object), "data");
+ var Body = Expression.Block(Expression.Convert(Expression.Convert(DataParam, data.GetType()), Type));
+
+ var Run = Expression.Lambda(Body, DataParam).Compile();
+ var ret = Run.DynamicInvoke(data);
+ return ret;
+ }
}
}
}else
targetValue = targetValue.ToString ();
}
- b.Source.Property.GetSetMethod ().Invoke (this, new object[] { targetValue });
+ if (targetValue != null)
+ b.Source.Property.GetSetMethod ().Invoke
+ (this, new object[] { b.Source.Property.PropertyType.Cast(targetValue)});
+ else
+ b.Source.Property.GetSetMethod ().Invoke
+ (this, new object[] { targetValue });
#endregion
//if no dyn update, skip jump table