/// <summary> /// Gets a fully formed using statement expanding any abbreviated statement beginning with using and ending with a semicolon. /// </summary> /// <param name="directive"> /// The directive to use. /// </param> /// <returns> /// The qualified using statement. /// </returns> internal static string GetFullyQualifiedStatement(this IUsingDirective directive) { if (directive is IUsingAliasDirective) { IUsingAliasDirective aliasDirective = directive as IUsingAliasDirective; return(string.Format("using {0} = {1};", aliasDirective.AliasName, directive.GetFullyQualifiedNamespace())); } IUsingNamespaceDirective namespaceDirective = directive as IUsingNamespaceDirective; return(namespaceDirective != null?string.Format("using {0};", directive.GetFullyQualifiedNamespace()) : directive.GetText()); }
/// <summary> /// Gets the root namespace of the Using directive after expanding any abbreviations. /// </summary> /// <param name="directive"> /// The directive to use. /// </param> /// <returns> /// The root namespace. /// </returns> internal static string GetRootNamespace(this IUsingDirective directive) { return(directive.GetFullyQualifiedNamespace().SubstringBefore('.').SubstringBefore(';')); }