public IConfiguredDataSource Create(IMemberMapperData mapperData) { var configuredCondition = GetConditionOrNull(mapperData); var value = DataSourceLambda.GetBody(mapperData); return(new ConfiguredDataSource( configuredCondition, value, ConfigInfo.IsSequentialConfiguration, ConfigInfo.HasTargetMemberMatcher(), mapperData)); }
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); }
protected override bool HasSameCriteriaAs(ConfiguredDataSourceFactoryBase otherDataSource) => DataSourceLambda.IsSameAs(otherDataSource?.DataSourceLambda);
public override bool AppliesTo(IQualifiedMemberContext context) => base.AppliesTo(context) && DataSourceLambda.Supports(context.RuleSet);
protected string GetDataSourceValueDescription() { var description = DataSourceLambda.GetDescription(ConfigInfo); return(DataSourceLambda.IsSourceMember ? description : "'" + description + "'"); }