public Type GetPropperBaseProjectionType()

in src/Epam.GraphQL/Configuration/RelationRegistry.cs [565:608]


        public Type GetPropperBaseProjectionType<TProjection, TEntity>()
            where TProjection : ProjectionBase<TEntity, TExecutionContext>, new() =>
            GetPropperBaseProjectionType<TProjection, TEntity>((first, second) => first.Equals(second));

        public Type GetPropperBaseProjectionType<TProjection, TEntity>(
            Func<IObjectGraphTypeConfigurator<TExecutionContext>, IObjectGraphTypeConfigurator<TExecutionContext>, bool> equalPredicate)
            where TProjection : ProjectionBase<TEntity, TExecutionContext>, new()
        {
            var foundType = typeof(TProjection);
            var baseType = typeof(TProjection).BaseType;

            while (true)
            {
                Guards.ThrowArgumentExceptionIf(
                    baseType == typeof(object),
                    "Invalid projection type",
                    nameof(TProjection));

                if (baseType.IsGenericType)
                {
                    var genericTypeDefinition = baseType.GetGenericTypeDefinition();
                    if (genericTypeDefinition.Assembly == GetType().Assembly)
                    {
                        return foundType;
                    }
                }

                if (baseType.IsAbstract)
                {
                    return foundType;
                }

                var projection = ResolveLoader<TProjection, TEntity>();
                var baseLoader = ResolveLoader(baseType, typeof(TEntity));

                if (equalPredicate(baseLoader.GetObjectGraphTypeConfigurator(), projection.GetObjectGraphTypeConfigurator())
                    && equalPredicate(baseLoader.GetInputObjectGraphTypeConfigurator(), projection.GetInputObjectGraphTypeConfigurator()))
                {
                    foundType = baseType;
                }

                baseType = baseType.BaseType;
            }
        }