Exemplo n.º 1
0
        public static IEnumerable <IDataSource> Create(DataSourceFindContext context)
        {
            if (context.TargetMember.IsCustom)
            {
                yield break;
            }

            if (context.DoNotUseSourceMemberDataSource())
            {
                if (context.DataSourceIndex == 0)
                {
                    if (context.UseFallbackComplexTypeDataSource())
                    {
                        yield return(ComplexTypeDataSource.Create(context.DataSourceIndex, context.MemberMappingData));
                    }
                }
                else if (context.UseFallbackForConditionalConfiguredDataSource())
                {
                    yield return(context.GetFallbackDataSource());
                }

                if (context.UseConfiguredDataSourcesOnly())
                {
                    yield break;
                }
            }

            if (context.ReturnSimpleTypeToTargetDataSources())
            {
                var updatedMapperData = new ChildMemberMapperData(
                    context.MatchingSourceMemberDataSource.SourceMember,
                    context.TargetMember,
                    context.MemberMapperData.Parent);

                var configuredRootDataSources = context
                                                .MapperContext
                                                .UserConfigurations
                                                .GetDataSourcesForToTarget(updatedMapperData);

                foreach (var configuredRootDataSource in configuredRootDataSources)
                {
                    yield return(configuredRootDataSource);
                }
            }

            yield return(context.MatchingSourceMemberDataSource);

            if (context.UseFallbackDataSource())
            {
                yield return(context.GetFallbackDataSource());
            }
        }
        public static IEnumerable <IDataSource> Create(DataSourceFindContext context)
        {
            if (TryGetMetaMemberNameParts(context, out var memberNameParts) &&
                TryGetMetaMember(memberNameParts, context, out var metaMember))
            {
                var dataSource = metaMember.GetDataSource();

                yield return(context.GetFinalDataSource(dataSource));

                if (dataSource.IsConditional)
                {
                    yield return(context.GetFallbackDataSource());
                }
            }
        }
        public static IEnumerable <IDataSource> Create(DataSourceFindContext context)
        {
            if (!UseMaptimeDataSources(context, out var maptimeDataSources))
            {
                yield break;
            }

            context.StopFind = true;

            foreach (var maptimeDataSource in maptimeDataSources)
            {
                yield return(context.GetFinalDataSource(maptimeDataSource));

                if (maptimeDataSource.IsConditional)
                {
                    continue;
                }

                yield break;
            }

            yield return(context.GetFallbackDataSource());
        }