コード例 #1
0
        public IConfiguredDataSource Create(IMemberMapperData mapperData)
        {
            var configuredCondition = GetConditionOrNull(mapperData);
            var value = DataSourceLambda.GetBody(mapperData);

            return(new ConfiguredDataSource(
                       configuredCondition,
                       value,
                       ConfigInfo.IsSequentialConfiguration,
                       ConfigInfo.HasTargetMemberMatcher(),
                       mapperData));
        }
コード例 #2
0
        private bool CannotBeReversed(out QualifiedMember targetMember, out string reason)
        {
            if (ValueCouldBeSourceMember == false)
            {
                targetMember = null;
                reason       = $"configured value '{DataSourceLambda.GetDescription(ConfigInfo)}' is not a source member";
                return(true);
            }

            if (ConfigInfo.HasCondition)
            {
                targetMember = null;
                reason       = $"configuration has condition '{ConfigInfo.GetConditionDescription()}'";
                return(true);
            }

            if (!TargetMember.IsReadable)
            {
                targetMember = null;
                reason       = $"target member '{GetTargetDescription()}' is not readable, so cannot be used as a source member";
                return(true);
            }

            if (!DataSourceLambda.TryGetSourceMember(out var sourceMemberLambda))
            {
                targetMember = null;
                reason       = $"configured value '{DataSourceLambda.GetDescription(ConfigInfo)}' is not a source member";
                return(true);
            }

            targetMember = sourceMemberLambda.ToTargetMemberOrNull(
                SourceType,
                ConfigInfo.MapperContext,
                out reason);

            if (targetMember != null)
            {
                return(false);
            }

            var sourceMember     = sourceMemberLambda.ToSourceMember(ConfigInfo.MapperContext);
            var sourceMemberPath = sourceMember.GetFriendlySourcePath(ConfigInfo);

            reason = $"source member '{sourceMemberPath}' is not a useable target member. {reason}";
            return(true);
        }
コード例 #3
0
 protected override bool HasSameCriteriaAs(ConfiguredDataSourceFactoryBase otherDataSource)
 => DataSourceLambda.IsSameAs(otherDataSource?.DataSourceLambda);
コード例 #4
0
 public override bool AppliesTo(IQualifiedMemberContext context)
 => base.AppliesTo(context) && DataSourceLambda.Supports(context.RuleSet);
コード例 #5
0
        protected string GetDataSourceValueDescription()
        {
            var description = DataSourceLambda.GetDescription(ConfigInfo);

            return(DataSourceLambda.IsSourceMember ? description : "'" + description + "'");
        }