FormatPath() публичный статический Метод

public static FormatPath ( string output, NChanges.Core.AssemblyInfo assembly ) : string
output string
assembly NChanges.Core.AssemblyInfo
Результат string
Пример #1
0
        public void Run(IEnumerable <string> args)
        {
            var extras = _optionSet.Parse(args);

            foreach (var arg in PathHelper.ExpandPaths(extras))
            {
                var absolutePath = Path.GetFullPath(arg);

                var assembly = Assembly.LoadFrom(absolutePath);

                var assemblyInfo = new AssemblyInfo();
                assemblyInfo.ReadAssembly(assembly, _excludePattern);

                if (_version != null)
                {
                    assemblyInfo.Version = _version;
                }

                var outputPath = PathHelper.FormatPath(_output, assemblyInfo);

                PathHelper.EnsureFolderExists(outputPath);

                using (var xmlWriter = new XmlTextWriter(outputPath, Encoding.UTF8)
                {
                    Formatting = Formatting.Indented
                })
                {
                    assemblyInfo.WriteXml(xmlWriter);
                }
            }
        }
Пример #2
0
        public void Run(IEnumerable <string> args)
        {
            var extras = _optionSet.Parse(args);

            var assemblies = new List <AssemblyInfo>();

            foreach (string arg in PathHelper.ExpandPaths(extras))
            {
                var assemblyInfo = new AssemblyInfo();

                using (var xmlReader = new XmlTextReader(arg))
                {
                    assemblyInfo.ReadXml(xmlReader);
                }

                assemblies.Add(assemblyInfo);
            }

            foreach (var group in assemblies.GroupBy(a => a.Name))
            {
                var reporter = new Reporter();

                foreach (var assembly in group)
                {
                    reporter.Assemblies.Add(assembly);
                }

                var report = reporter.GenerateReport();

                var outputPath = PathHelper.FormatPath(_output, report);

                PathHelper.EnsureFolderExists(outputPath);

                using (var xmlWriter = new XmlTextWriter(outputPath, Encoding.UTF8)
                {
                    Formatting = Formatting.Indented
                })
                {
                    report.WriteXml(xmlWriter);
                }

                if (!string.IsNullOrEmpty(_transform))
                {
                    var transform = new XslCompiledTransform();
                    transform.Load(_transform);

                    var document = new XPathDocument(outputPath);

                    var transformOutput = PathHelper.FormatPath(_transformOutput, report);

                    using (var stream = new FileStream(transformOutput, FileMode.Create))
                    {
                        transform.Transform(document, null, stream);
                        stream.Flush();
                    }
                }
            }
        }
Пример #3
0
        public void Run(IEnumerable <string> args)
        {
            var extras = _optionSet.Parse(args);

            if (!string.IsNullOrEmpty(_name) && !_multipleSheets)
            {
                _columns = "name," + _columns;
            }

            _splitColumns = _columns.Split(',');

            var workbook = new HSSFWorkbook();

            var headerCellStyle = workbook.CreateCellStyle();
            var headerFont      = workbook.CreateFont();

            headerFont.Boldweight = (short)FontBoldWeight.BOLD;
            headerCellStyle.SetFont(headerFont);

            string fileName = null;

            ISheet worksheet = null;

            foreach (var path in PathHelper.ExpandPaths(extras))
            {
                var report = LoadReport(path);

                if (fileName == null)
                {
                    fileName = PathHelper.FormatPath(_output, report);
                }

                if (report.HasChanges())
                {
                    _currentName = report.Name;

                    if (!string.IsNullOrEmpty(_name))
                    {
                        var match = Regex.Match(_currentName, _name);

                        if (match.Success)
                        {
                            _currentName = match.Groups
                                           .Cast <Group>()
                                           .Skip(1)
                                           .First(g => !string.IsNullOrEmpty(g.Value))
                                           .Value;
                        }
                    }

                    if (_multipleSheets || worksheet == null)
                    {
                        worksheet = workbook.CreateSheet(_multipleSheets ? _currentName : "Changes");
                        AddHeaders(worksheet, headerCellStyle);
                    }

                    AddData(report, worksheet);

                    if (_multipleSheets)
                    {
                        FinalizeWorkSheet(worksheet);
                    }
                }
            }

            if (!_multipleSheets)
            {
                FinalizeWorkSheet(worksheet);
            }

            workbook.Write(new FileStream(fileName, FileMode.Create));
        }