Example #1
0
        public SharpKitTempProvider(IUniqueNameProvider tempNameProvider, ICompilerConfiguration configuration)
        {
            if (!Directory.Exists(configuration.TempDirectory()))
            {
                Directory.CreateDirectory(configuration.TempDirectory());
            }

            TempDirectory = Path.Combine(configuration.TempDirectory(), tempNameProvider.Next());
            if (!Directory.Exists(TempDirectory))
            {
                Directory.CreateDirectory(TempDirectory);
            }

            string key = Guid.NewGuid().ToString("N");

            InputCsFileName = String.Format("{0}.cs", key);
            InputCsFilePath = Path.Combine(TempDirectory, InputCsFileName);

            if (File.Exists(InputCsFilePath))
            {
                File.Delete(InputCsFilePath);
            }

            OutputDllFileName = String.Format("{0}.dll", key);
            OutputDllFilePath = Path.Combine(TempDirectory, OutputDllFileName);

            if (File.Exists(OutputDllFilePath))
            {
                File.Delete(OutputDllFilePath);
            }

            OutputJsFileName = String.Format("{0}.js", key);
            OutputJsFilePath = Path.Combine(TempDirectory, OutputJsFileName);

            if (File.Exists(OutputJsFilePath))
            {
                File.Delete(OutputJsFilePath);
            }

            ManifestFileName = String.Format("{0}.skccache", key);
            ManifestFilePath = Path.Combine(TempDirectory, ManifestFileName);

            if (File.Exists(ManifestFilePath))
            {
                File.Delete(ManifestFilePath);
            }
        }
Example #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());
            }
        }
 public ReportContainer(IUniqueNameProvider nameProvider)
 {
     _nameProvider = nameProvider;
     Properties    = new Dictionary <string, string>();
     Tables        = new Dictionary <string, ICSVTable>();
 }
Example #4
0
        public static CSVTable FindTable(IUniqueNameProvider _nameProvider, int row, int col, string[,] csvReport)
        {
            CSVTable    table         = new CSVTable();
            ICSVAddress topLeftAddess = GoToTopLeftAddress(row, col, csvReport);
            ICSVAddress nextAddress   = topLeftAddess;

            while (nextAddress.IsValid() && !nextAddress.IsBlank() && !nextAddress.Value.IsNumeric())
            {
                ICSVAddress address = nextAddress;
                table.AddAddress(address);

                //Add the header while you're at it
                table.AddHeader(_nameProvider.GetUniqueName(table.Headers.ToArray(), address.Value));

                nextAddress = new CSVAddress(address.Row, address.Column + 1, csvReport);
            }
            if (table.Headers.Count() < 3)
            {
                return(null);
            }

            //int columnDepth = table.GetLongestColumn(csvReport, (r, c, report) => { return report[r, c] != string.Empty; });
            int endColumns = GetTopRightAddress(row, col, csvReport).Column + 1;

            int rowWidth = table.Addresses.Count(); //The current count of the addresses is only the header width: g2g
            //int endRows = topLeftAddess.Row + table.GetRowCount(topLeftAddess, csvReport, (a)=> { return a.IsValid() && !a.IsBlank() && !a.IsZero(); });

            //Add the headers to the table addresses
            //for(int header = topLeftAddess.Column; header < endColumns; header++)
            //{
            //    table.AddAddress(new CSVAddress(topLeftAddess.Row, header, csvReport));
            //}

            //int currentCol = topLeftAddess.Column;
            int currentRow = topLeftAddess.Row + 1;

            //List<string[]> records = new List<string[]>();
            string[] record = csvReport.SubArray(currentRow, topLeftAddess.Column, rowWidth);
            //while (!record.OnlyContains(new string[]{ string.Empty, "0" }))
            while (!record.OnlyContains(new Func <string, bool>[]
            {
                (s) => s == string.Empty,
                (s) => s == "0",
                (s) => s.IsNumeric() && double.Parse(s) == 0
            }
                                        ))
            {
                table.AddRecord(record);
                for (int tableColumn = 0; tableColumn < rowWidth; tableColumn++)
                {
                    table.AddAddress(new CSVAddress(currentRow, topLeftAddess.Column + tableColumn, csvReport));
                }
                currentRow++;
                if (currentRow < csvReport.GetLength(0))
                {
                    record = csvReport.SubArray(currentRow, topLeftAddess.Column, rowWidth);
                }
                else
                {
                    break;
                }
            }
            //while (currentRow < endRows)
            //{
            //    CSVAddress address = new CSVAddress(currentRow, currentCol, csvReport);
            //    table.AddAddress(address);
            //    record.Add(address.Value);
            //    currentCol++;
            //    if (currentCol >= endColumns)
            //    {
            //        string[] tuple = record.ToArray();
            //        if (!tuple.OnlyContains(new string[] { string.Empty, "0"}))
            //        {
            //            table.AddRecord(record.ToArray());
            //            record = new List<string>();
            //            currentCol = topLeftAddess.Column;
            //            currentRow++;
            //        }
            //        else break;
            //    }
            //}
            if (table.Records.Count() < 1)
            {
                return(null);
            }

            return(table);
        }
 public CSVReportReader(IReportContainer reportContainer, IUniqueNameProvider nameProvider)
 {
     _reportContainer = reportContainer == null ? new ReportContainer(nameProvider): reportContainer;
     _nameProvider    = nameProvider;
 }
 public NamedDestinationFactory(IUniqueNameProvider nameProvider)
 {
     _nameProvider = nameProvider;
 }