Aqueduct.Configuration.Converter.TypeConverter.ParseType C# (CSharp) Method

ParseType() public method

public ParseType ( string typeName ) : Type
typeName string
return System.Type
        public Type ParseType(string typeName)
        {
            ConfigGuard.ArgumentNotNull(typeName, "typeName", "ParseType does not accept null");

            string parsedTypeName = ResolveGenericAliases(typeName);

            int startIndex = parsedTypeName.IndexOf('[');
            int endIndex = parsedTypeName.LastIndexOf(']');

            if (startIndex == -1)
            {
                // try to load the non-generic type (e.g. System.Int32)
                return GetNonGenericType(parsedTypeName);
            }
            else
            {
                // get the FullName of the non-generic type (e.g. System.Collections.Generic.List`1)
                string fullName = parsedTypeName.Substring(0, startIndex);
                if (parsedTypeName.Length - endIndex - 1 > 0)
                    fullName += parsedTypeName.Substring(endIndex + 1, parsedTypeName.Length - endIndex - 1);

                // parse the child type arguments for this generic type (recursive)
                List<Type> list = new List<Type>();
                string typeArguments = parsedTypeName.Substring(startIndex + 1, endIndex - startIndex - 1);
                foreach (string typeArgument in typeArguments.Split(",".ToCharArray()))
                {
                    list.Add(GetNonGenericType(typeArgument.Trim()));
                }

                return GetNonGenericType(fullName).MakeGenericType(list.ToArray());
            }
        }