예제 #1
0
        /// <summary>
        /// Creates a closed generic type from the a generic type definition (like <see cref="IEnumerable{T}"/>) and type arguments (like <see cref="string"/>).
        /// </summary>
        /// <param name="genericTypeDefinition">The generic type definition</param>
        /// <param name="typeArguments">Type arguments</param>
        /// <returns>The generic type.</returns>
        public static TypeSyntax CreateGenericTypeFromGenericTypeDefinition(TypeSyntax genericTypeDefinition, params TypeSyntax[] typeArguments)
        {
            GenericNameSyntax openType   = genericTypeDefinition.DescendantNodes().OfType <GenericNameSyntax>().Single();
            GenericNameSyntax closedType = openType.AddTypeArgumentListArguments(typeArguments);

            return(genericTypeDefinition.ReplaceNode(openType, closedType));
        }