コード例 #1
0
        private static bool TryExecuteProcess(SharpKitTempProvider tempProvider, string exePath, string args, out ICompilerResult result)
        {
            StringCollection outputCollection = new StringCollection();
            StringCollection errorCollection  = new StringCollection();

            int cscResultCode = ExecuteProcess(tempProvider.TempDirectory, exePath, args, outputCollection, errorCollection);

            if (cscResultCode != 0)
            {
                result = new CompilerResult(
                    ParseErrorOutput(errorCollection),
                    outputCollection
                    );
                return(false);
            }

            result = null;
            return(true);
        }
コード例 #2
0
        public static ICompilerResult Generate(IUniqueNameProvider tempNameProvider, ICompilerConfiguration configuration, TextReader input, TextWriter output)
        {
            Ensure.NotNull(tempNameProvider, "tempNameProvider");
            Ensure.NotNull(configuration, "configuration");
            Ensure.NotNull(input, "input");
            Ensure.NotNull(output, "output");

            using (SharpKitTempProvider tempProvider = new SharpKitTempProvider(tempNameProvider, configuration))
            {
                tempProvider.WriteInput(input);

                SharpKitProcessBuilder skBuilder = new SharpKitProcessBuilder()
                                                   .Executable(SkcPath)
                                                   .Rebuild()
                                                   .OutDll(tempProvider.OutputDllFilePath)
                                                   .OutputGeneratedJsFile(tempProvider.OutputJsFilePath)
                                                   .ManifestFile(tempProvider.ManifestFileName)
                                                   .AddSourceFile(tempProvider.InputCsFileName)
                                                   .AddPlugin(configuration.Plugins())
                                                   .AddReference(CopyReferences(configuration));

                ICompilerResult result;

                if (!TryExecuteProcess(tempProvider, SkcPath, skBuilder.Arguments(), out result))
                {
                    return(result);
                }

                if (!tempProvider.TryCopyOutputJs(output))
                {
                    return(new CompilerResult(
                               new List <IErrorInfo>()
                    {
                        new ErrorInfo(0, 0, "No js files were generated")
                    },
                               new StringCollection()
                               ));
                }

                return(new CompilerResult());
            }
        }