Beispiel #1
0
        public static Delegate GetGetterAs(DataViewType typeDst, DataViewRow row, DataViewSchema.Column col)
        {
            Contracts.CheckValue(typeDst, "typeDst");
            Contracts.CheckParam(typeDst.IsPrimitive(), "typeDst");
            Contracts.CheckValue(row, "row");
            Contracts.CheckParam(0 <= col.Index && col.Index < row.Schema.Count, "col");
            Contracts.CheckParam(row.IsColumnActive(col), "col", "column was not active");

            var typeSrc = row.Schema[col.Index].Type;

            Contracts.Check(typeSrc.IsPrimitive(), "Source column type must be primitive");

            Func <DataViewType, DataViewType, DataViewRow, DataViewSchema.Column, ValueGetter <int> > del = GetGetterAsCore <int, int>;
            var methodInfo = del.GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(typeSrc.RawType, typeDst.RawType);

            return((Delegate)methodInfo.Invoke(null, new object[] { typeSrc, typeDst, row, col }));
        }