Exemplo n.º 1
0
        private object AfterCast(ViewColumnType viewColumnType
                                 , ViewColumnInfo aViewColumnInfo
                                 , object propertyValue)
        {
            MethodInfo methodInfo = _castEditorType.GetMethod("AfterCast"
                                                              , new System.Type[] { viewColumnType.GetType(),
                                                                                    this.GetType(),
                                                                                    aViewColumnInfo.GetType(),
                                                                                    typeof(object) });

            return(methodInfo.Invoke(_castEditor
                                     , new object[] { viewColumnType,
                                                      this,
                                                      aViewColumnInfo,
                                                      propertyValue }));
        }
Exemplo n.º 2
0
 private object BeforeCast(ViewColumnType viewColumnType
                           , ViewColumnInfo aViewColumnInfo
                           , object viewColumnValue)
 {
     try {
         MethodInfo methodInfo = _castEditorType.GetMethod("BeforeCast",
                                                           new System.Type[] { viewColumnType.GetType(),
                                                                               this.GetType(),
                                                                               aViewColumnInfo.GetType(),
                                                                               typeof(object) });
         return(methodInfo.Invoke(_castEditor,
                                  new object[] { viewColumnType,
                                                 this,
                                                 aViewColumnInfo,
                                                 viewColumnValue }));
     } catch (System.Exception ex) {
         MethodInfo[] m = _castEditorType.GetMethods();
         throw;
     }
 }
Exemplo n.º 3
0
        public object CastToPropertyType(object viewColumnValue
                                         , ViewColumnInfo aViewColumnInfo
                                         , System.Type propertyTypeObj
                                         , ColumnInfo aColumnInfo = null)
        {
            //columnValueがnullまたはDbNullの場合、NULL表現値を返す
            if (viewColumnValue == null || viewColumnValue is DBNull)
            {
                if (this.IsNullableType(propertyTypeObj))
                {
                    //変換先プロパティ型がNull許容型ならば、nullがNull表現値である
                    return(null);
                }
                else
                {
                    //Null許容型でないならば、データ型固有のNull表現値を返す
                    return(this.GetPropertyType(propertyTypeObj).GetNullValue());
                }
            }

            //変換先プロパティがNull許容型ならば、Null許容型が含むジェネリックパラメータ型に
            //対応するPropertyTypeを取得する
            PropertyType aPropertyType = null;

            if (this.IsNullableType(propertyTypeObj))
            {
                aPropertyType = this.GetPropertyType(this.GetGenericParameterType(propertyTypeObj));
            }
            else
            {
                aPropertyType = this.GetPropertyType(propertyTypeObj);
            }

            //ViewColumnTypeを生成する
            ViewColumnType viewColumnType = this.GetViewColumnType(aViewColumnInfo);

            //ADO.NETが返したデータ型から、プロパティ型にキャスト処理を行う
            return(viewColumnType.CastTo(aPropertyType, aViewColumnInfo, viewColumnValue));
        }