Catel.Reflection.TypeCache.GetTypeBySplittingInternals C# (CSharp) Method

GetTypeBySplittingInternals() private static method

Gets the type by splitting internal types. This means that System.Collections.List`1[[MyCustomType.Item]] will be splitted and resolved separately.
private static GetTypeBySplittingInternals ( string typeWithInnerTypes ) : Type
typeWithInnerTypes string The type with inner types.
return System.Type
        private static Type GetTypeBySplittingInternals(string typeWithInnerTypes)
        {
            // Try fast method first
            var fastType = Type.GetType(typeWithInnerTypes);
            if (fastType != null)
            {
                return fastType;
            }

            if (typeWithInnerTypes.EndsWith("[]"))
            {
                // Array type
                var arrayTypeElementString = typeWithInnerTypes.Replace("[]", string.Empty);
                var arrayTypeElement = TypeCache.GetType(arrayTypeElementString);
                if (arrayTypeElement != null)
                {
                    return arrayTypeElement.MakeArrayType();
                }

                return null;
            }

            var innerTypes = new List<Type>();
            var innerTypesShortNames = TypeHelper.GetInnerTypes(typeWithInnerTypes);
            if (innerTypesShortNames.Length > 0)
            {
                foreach (var innerTypesShortName in innerTypesShortNames)
                {
                    var innerType = TypeCache.GetType(innerTypesShortName);
                    if (innerType == null)
                    {
                        return null;
                    }

                    innerTypes.Add(innerType);
                }

                var innerTypesNames = new List<string>();
                foreach (var innerType in innerTypes)
                {
                    innerTypesNames.Add(innerType.AssemblyQualifiedName);
                }

                var firstBracketIndex = typeWithInnerTypes.IndexOf('[');
                var typeWithImprovedInnerTypes = string.Format("{0}[{1}]", typeWithInnerTypes.Substring(0, firstBracketIndex), TypeHelper.FormatInnerTypes(innerTypesNames.ToArray()));

                var fallbackType = Type.GetType(typeWithImprovedInnerTypes);
                return fallbackType;
            }

            // This is not yet supported or type is really not available
            return null;
        }