Esempio n. 1
0
        public StringBuilder GetUsingBuilder()
        {
            Using(UsingRecoder.Types);
            //如果用户想使用自定义的Using
            if (AssemblyBuilder.CustomUsingShut)
            {
                UsingScript = new StringBuilder();
                foreach (var @using in _usings)
                {
                    UsingScript.AppendLine($"using {@using};");
                }
            }
            else
            {
                //使用全局Using
                UsingScript.Append(DefaultUsing.DefaultScript);

                //把当前域中的using全部加上
                Using(AssemblyBuilder.Compiler.Domain.GetPluginAssemblies());
                foreach (var @using in _usings)
                {
                    //如果全局已经存在using了,就不加了
                    if (!DefaultUsing.HasElement(@using))
                    {
                        UsingScript.AppendLine($"using {@using};");
                    }
                }
            }


            return(UsingScript);
        }
Esempio n. 2
0
        public StringBuilder GetUsingBuilder()
        {
#if DEBUG
            Stopwatch stopwatch = new();
            stopwatch.Start();
#endif
            var usingScript = new StringBuilder();

            //如果用户想使用自定义的Using
            if (!_useGlobalUsing)
            {
                foreach (var @using in UsingRecorder._usings)
                {
                    usingScript.AppendLine($"using {@using};");
                }
                //使用全局Using
                if (_autoLoadDomainUsing)
                {
                    foreach (var @using in AssemblyBuilder.Domain.UsingRecorder._usings)
                    {
                        if (!UsingRecorder.HasUsing(@using))
                        {
                            usingScript.AppendLine($"using {@using};");
                        }
                    }
                }
            }
            else
            {
                //使用全局Using
                if (_autoLoadDomainUsing && AssemblyBuilder.Domain.Name != "Default")
                {
                    foreach (var @using in AssemblyBuilder.Domain.UsingRecorder._usings)
                    {
                        if (!DefaultUsing.HasElement(@using) && !UsingRecorder.HasUsing(@using))
                        {
                            usingScript.AppendLine($"using {@using};");
                        }
                    }
                }

                //把当前域中的using全部加上
                foreach (var @using in UsingRecorder._usings)
                {
                    //如果全局已经存在using了,就不加了
                    if (!DefaultUsing.HasElement(@using))
                    {
                        usingScript.AppendLine($"using {@using};");
                    }
                }
                usingScript.Append(DefaultUsing.UsingScript);
            }
#if DEBUG
            stopwatch.StopAndShowCategoreInfo("[using]", "using 组合", 3);
#endif
            return(usingScript);
        }