Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyMapperCustomBase{TEntity, TProperty}"/> class.
        /// </summary>
        /// <param name="srcePropertyExpression">The <see cref="LambdaExpression"/> to reference the source entity property.</param>
        /// <param name="destPropertyName">The name of the destination property (defaults to <see cref="SrcePropertyName"/> where null).</param>
        /// <param name="operationTypes">The <see cref="Mapper.OperationTypes"/> selection to enable inclusion or exclusion of property (default to <see cref="OperationTypes.Any"/>).</param>
        protected PropertyMapperCustomBase(Expression <Func <TSrce, TSrceProperty> > srcePropertyExpression, string destPropertyName, OperationTypes operationTypes = OperationTypes.Any)
        {
            SrcePropertyExpression = PropertyExpression.Create(srcePropertyExpression ?? throw new ArgumentNullException(nameof(srcePropertyExpression)));
            SrcePropertyInfo       = TypeReflector.GetPropertyInfo(typeof(TSrce), SrcePropertyName);
            DestPropertyName       = string.IsNullOrEmpty(destPropertyName) ? SrcePropertyExpression.Name : destPropertyName;
            OperationTypes         = operationTypes;

            if (SrcePropertyInfo.PropertyType.IsClass && SrcePropertyInfo.PropertyType != typeof(string))
            {
                SrceComplexTypeReflector = ComplexTypeReflector.Create(SrcePropertyInfo);
            }
        }