private static Type CreateConcreteType()

in src/Core/Vipr/odataDemo.cs [2135:2231]


        private static Type CreateConcreteType(Type tsourceType)

        {

            var tsourceTypeInfo = System.Reflection.IntrospectionExtensions.GetTypeInfo(tsourceType);

            if (tsourceTypeInfo.IsGenericType)

            {

                var arguments = tsourceTypeInfo.GenericTypeArguments;

                bool modified = false;



                for(int i = 0; i < arguments.Length; i++)

                {

                    var converted = CreateConcreteType(arguments[i]);

                    if (converted != null)

                    {

                        arguments[i] = converted;

                        modified = true;

                    }

                }



                if (!modified)

                {

                    return null;

                }



                // Properties declared as IPagedCollection on the interface are declared as IList on the concrete type

                if (tsourceTypeInfo.GetGenericTypeDefinition() == typeof(IPagedCollection<>))

                {

                    return typeof(IList<>).MakeGenericType(arguments);

                }



                return tsourceTypeInfo.GetGenericTypeDefinition().MakeGenericType(arguments);

            }



            const string Fetcher = "Fetcher";

            if (System.Linq.Enumerable.Any<System.Reflection.CustomAttributeData>(

                tsourceTypeInfo.CustomAttributes,

                i => i.AttributeType == typeof(LowerCasePropertyAttribute)))

            {

                string typeName = tsourceTypeInfo.Namespace + "." + tsourceTypeInfo.Name.Substring(1);

                if (typeName.EndsWith(Fetcher))

                {

                    typeName = typeName.Substring(typeName.Length - Fetcher.Length);

                }

                return tsourceTypeInfo.Assembly.GetType(typeName);

            }

            else

            {

                return null;

            }

        }