示例#1
0
 /// <summary>
 /// Builds a new <see cref="CodeNamespaceImport"/> object based on the
 /// namespace of <paramref name="ns"/>.
 /// </summary>
 /// <param name="ns">
 /// The <see cref="String"/> namespace name.
 /// </param>
 /// <param name="options">
 /// The <see name="NamespaceAliasOptions"/> object to generate the
 /// <see cref="CodeNamespaceImport"/> object with.
 /// </param>
 /// <returns>
 /// A new <see cref="CodeNamespaceImport"/> for the specified type.
 /// </returns>
 public static CodeNamespaceImport GetCodeNamespaceImport(this string ns, NamespaceAliasOptions options)
 {
     if (TypeExtensions.NamespaceAliases.ContainsKey(ns))
     {
         return(options.BuildNamespaceImport(ns,
                                             TypeExtensions.NamespaceAliases[ns]));
     }
     return(new CodeNamespaceImport(ns));
 }
示例#2
0
 /// <summary>
 /// Builds a new <see cref="CodeNamespaceImport"/> object based on the
 /// namespace of <paramref name="t"/>.
 /// </summary>
 /// <param name="t">
 /// The <see cref="Type"/> object to get the namespace from.
 /// </param>
 /// <param name="options">
 /// The <see name="NamespaceAliasOptions"/> object to generate the
 /// <see cref="CodeNamespaceImport"/> object with.
 /// </param>
 /// <returns>
 /// A new <see cref="CodeNamespaceImport"/> for the specified type.
 /// </returns>
 public static CodeNamespaceImport GetCodeNamespaceImport(this Type t, NamespaceAliasOptions options)
 {
     return(t.Namespace.GetCodeNamespaceImport(options));
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LanguageDefinition"/> class
 /// with the <see cref="CodeDomProvider"/> object that will be used to
 /// create the language source code and predefined <see cref="NamespaceAliasOptions"/>.
 /// </summary>
 /// <param name="opts">
 /// Custom <see cref="NamespaceAliasOptions"/> for the language definition.
 /// </param>
 /// <param name="provider">
 /// The <see cref="CodeDomProvider"/> object for the new <see cref="LanguageDefinition"/>
 /// provider.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="opts"/> or <paramref name="provider"/> is <see langword="null"/>.
 /// </exception>
 protected LanguageDefinition(NamespaceAliasOptions opts, CodeDomProvider provider)
 {
     Options      = opts ?? throw new ArgumentNullException(nameof(opts));
     Provider     = provider ?? throw new ArgumentNullException(nameof(provider));
     Highlighting = HighlightingManager.Instance.GetDefinitionByExtension("." + Provider.FileExtension);
 }