public void Initialize(PropertyMapperConfig config)
        {
            Config = config;

            // Create accessor for the column property
            var columnProp = typeof(IGenericColumns).GetProperty(config.Column);

            if (columnProp == null || columnProp.PropertyType != typeof(TColumn))
            {
                throw new ArgumentException($"Column not found or type mismatch {config.PropertyName}");
            }

            ColumnAccessor = ReflectionTool.PropertyAccessor <IGenericColumns, TColumn>(columnProp);

            // Retrieve and validate properties
            var objectProp = TargetType.GetProperty(config.PropertyName);

            if (objectProp == null)
            {
                throw new ArgumentException($"Target type {TargetType.Name} does not have a property {config.PropertyName}");
            }

            // Create delegates for the object property as well
            ObjectAccessor = CreatePropertyAccessor(objectProp);
        }
예제 #2
0
 public void Initialize(PropertyMapperConfig config)
 {
     // Retrieve and validate properties
     Property = _targetType.GetProperty(config.PropertyName);
 }