Example #1
0
        /// <summary>
        /// 添加要编译的命名空间
        /// </summary>
        /// <param name="namespaceName"></param>
        /// <param name="builder"></param>
        /// <returns></returns>
        public CompilationBuilder WithNamespace(string namespaceName, Action <NamespaceBuilder> builder)
        {
            if (string.IsNullOrEmpty(namespaceName))
            {
                throw new ArgumentNullException(nameof(namespaceName));
            }

            NamespaceBuilder space = new NamespaceBuilder(namespaceName);

            builder.Invoke(space);
            _state.Namespaces.Add(space);
            return(this);
        }
Example #2
0
 /// <summary>
 /// 添加要编译的命名空间
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public CompilationBuilder WithNamespace(NamespaceBuilder builder)
 {
     _state.Namespaces.Add(builder);
     return(this);
 }
 /// <summary>
 /// <b>自动</b>添加 using 命名空间
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public static NamespaceBuilder WithAutoUsing(this NamespaceBuilder builder)
 {
     builder.WithUsing(DependencyContext.Default.CompileLibraries.Select(x => x.Name).ToArray());
     return(builder);
 }