public override DynamicMetaObject BindConvert(ConvertBinder binder) { var retType = binder.ReturnType.GetTypeInfo(); var isIDisposable = retType == Types.IDisposable; DynamicRowConverter?converter; BindingRestrictions restrictions; if (isIDisposable) { converter = null; restrictions = BindingRestrictions.GetTypeRestriction(Expression, Types.DynamicRow); } else { var ctx = ReadContext.ConvertingRow(Row.Owner.Options, Row.RowNumber, Row.Context); converter = Row.Converter.GetDynamicRowConverter(in ctx, Row.Columns, retType); var selfAsRow = Expression.Convert(Expression, Types.DynamicRow); var columns = Expression.Field(selfAsRow, Fields.DynamicRow.Columns); restrictions = DynamicExpressionHelper.MakeRestrictions(Types.DynamicRow, Expression, converter, selfAsRow, columns, retType); } var selfAsDynamicRow = Expression.Convert(Expression, Types.DynamicRow); var selfAsITestableDispoable = Expression.Convert(Expression, Types.ITestableDisposable); var assertNotDisposed = DynamicExpressionHelper.MakeAssertNotDisposedExpression(selfAsITestableDispoable); return(DynamicExpressionHelper.BindConvertFor(restrictions, selfAsDynamicRow, selfAsDynamicRow, assertNotDisposed, Row, retType, converter, null, null)); }
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) { var restrictions = BindingRestrictions.GetTypeRestriction(Expression, Types.DynamicRow); var selfAsITestable = Expression.Convert(Expression, Types.ITestableDisposable); return(DynamicExpressionHelper.BindGetMemberFor(restrictions, Expression, selfAsITestable, binder, null, null)); }
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) { var restrictions = BindingRestrictions.GetTypeRestriction(Expression, Types.DynamicRowRange); GetCommonExpressions(out var selfAsDynamicRowRange, out var offset, out var length, out var dynamicRow); var selfAsITestableDisposable = Expression.Convert(selfAsDynamicRowRange, Types.ITestableDisposable); return(DynamicExpressionHelper.BindGetMemberFor(restrictions, dynamicRow, selfAsITestableDisposable, binder, offset, length)); }
public override DynamicMetaObject BindConvert(ConvertBinder binder) { GetCommonExpressions(out var selfAsDynamicRowRange, out var offset, out var length, out var dynamicRow); var row = Range.Parent; var retType = binder.ReturnType.GetTypeInfo(); var isIDisposable = retType == Types.IDisposable; DynamicRowConverter?converter; BindingRestrictions restrictions; if (isIDisposable) { converter = null; restrictions = BindingRestrictions.GetTypeRestriction(Expression, Types.DynamicRowRange); } else { var cols = Range.Columns; var ctx = row.GetReadContext(Range.Offset, Range.Length); converter = row.Converter.GetDynamicRowConverter(in ctx, cols, retType); var callGetColumn = Expression.Field(selfAsDynamicRowRange, Fields.DynamicRowRange.Columns); var ienumerableOfColumnIdentifiers = Types.IEnumerableOfT.MakeGenericType(Types.ColumnIdentifier).GetTypeInfo(); var asIEnumerable = Expression.Convert(callGetColumn, ienumerableOfColumnIdentifiers); restrictions = DynamicExpressionHelper.MakeRestrictions(Types.DynamicRowRange, Expression, converter, dynamicRow, asIEnumerable, retType); } var selfAsITestableDisposable = Expression.Convert(Expression, Types.ITestableDisposable); var assertNotDisposed = DynamicExpressionHelper.MakeAssertNotDisposedExpression(selfAsITestableDisposable); return(DynamicExpressionHelper.BindConvertFor(restrictions, selfAsDynamicRowRange, dynamicRow, assertNotDisposed, Range.Parent, retType, converter, offset, length)); }