private static Expression BuildExtractExpressionForProperty( PropertyInfo propertyInfo, Expression interop, Expression dataHandle, Expression result) { // skip property from mapping if (Attribute.IsDefined(propertyInfo, typeof(SapIgnoreAttribute))) { return(null); } SapNameAttribute nameAttribute = propertyInfo.GetCustomAttribute <SapNameAttribute>(); ConstantExpression name = Expression.Constant(nameAttribute?.Name ?? propertyInfo.Name.ToUpper()); Expression property = Expression.Property(result, propertyInfo); var arguments = new Collection <Expression> { interop, dataHandle, name }; bool convertToNonNullable = false; MethodInfo extractMethod = null; if (propertyInfo.PropertyType == typeof(string)) { extractMethod = GetMethodInfo(() => StringField.Extract(default, default, default));
public void Constructor_PassName_ShouldSetNameProperty() { // Act var attribute = new SapNameAttribute("SomeName"); // Assert attribute.Name.Should().Be("SomeName"); }
private static Expression BuildApplyExpressionForProperty( PropertyInfo propertyInfo, Expression interopParameter, Expression dataHandleParameter, Expression inputParameter) { // skip property from mapping if (Attribute.IsDefined(propertyInfo, typeof(SapIgnoreAttribute))) { return(null); } SapNameAttribute nameAttribute = propertyInfo.GetCustomAttribute <SapNameAttribute>(); ConstantExpression name = Expression.Constant(nameAttribute?.Name ?? propertyInfo.Name.ToUpper()); // var value = propertyInfo.GetValue(input); Expression property = Expression.Property(inputParameter, propertyInfo); ConstructorInfo fieldConstructor = null; if (propertyInfo.PropertyType == typeof(string)) { // new RfcStringField(name, (string)value); fieldConstructor = GetFieldConstructor(() => new StringField(default, default));