Ejemplo n.º 1
0
        public void Write(object obj, object val)
        {
            string strType = field.FieldType.ToString();

            if ((val != null) && !field.FieldType.Equals(val.GetType()))
            {
                switch (strType)
                {
                case "System.String":
                    val = Convert.ToString(val);
                    break;

                case "System.Int16":
                    val = Convert.ToInt16(val);
                    break;

                case "System.Int32":
                    val = Convert.ToInt32(val);
                    break;

                case "System.Int64":
                    val = Convert.ToInt64(val);
                    break;

                case "System.Decimal":
                    val = Convert.ToDecimal(val);
                    break;

                case "System.DateTime":
                    val = Convert.ToDateTime(val);
                    break;
                }
            }

            DynamicMethodCompiler.GetCachedSetFieldHandlerDelegate(obj.GetType(), field)(obj, val);
        }