/// <summary> /// Returns the text that the constructor should have from the containing type declaration with either with 'less than' and 'greater than' signs escaped or not. /// </summary> /// <param name="constructorDeclaration"> /// The constructor to use. /// </param> /// <param name="encodeHtmlTags"> /// If True then <see cref="ITypeParameterOfTypeDeclaration"/> will have {} instead of < and >. /// </param> /// <returns> /// A string of the text. /// </returns> public static string CreateConstructorDescriptionText(IConstructorDeclaration constructorDeclaration, bool encodeHtmlTags) { ICSharpTypeDeclaration containingTypeDeclaration = constructorDeclaration.GetContainingTypeDeclaration(); string newName = constructorDeclaration.DeclaredName; if (containingTypeDeclaration.TypeParameters.Count > 0) { newName += encodeHtmlTags ? "{" : "<"; for (int i = 0; i < containingTypeDeclaration.TypeParameters.Count; i++) { ITypeParameterOfTypeDeclaration parameterDeclaration = containingTypeDeclaration.TypeParameters[i]; newName += parameterDeclaration.DeclaredName; if (i < containingTypeDeclaration.TypeParameters.Count - 1) { newName += ","; } } newName += encodeHtmlTags ? "}" : ">"; } return newName; }
/// <summary> /// Indicates whether the type of the constructor passed in is a struct. /// </summary> /// <param name="constructorDeclaration"> /// The constructor of the type to check. /// </param> /// <returns> /// True if containing type is a struct. /// </returns> public static bool IsContainingTypeAStruct(IConstructorDeclaration constructorDeclaration) { ICSharpTypeDeclaration typeDeclaration = constructorDeclaration.GetContainingTypeDeclaration(); return typeDeclaration is IStructDeclaration; }