Пример #1
0
        private static Stream ReadFile(IDiffFile file, Func <string, IDiffFile> fileGetter)
        {
            if (file.Path.EndsWith(".xslt", StringComparison.OrdinalIgnoreCase))
            {
                var report = InnovatorPackage.ReadReport(file.Path, p =>
                {
                    var f = fileGetter(p);
                    if (f != null)
                    {
                        return(f.OpenRead());
                    }
                    return(new MemoryStream(Encoding.UTF8.GetBytes("<Result><Item></Item></Result>")));
                });

                var result = new MemoryStream();
                using (var writer = XmlWriter.Create(result, new XmlWriterSettings
                {
                    OmitXmlDeclaration = true,
                    Indent = true,
                    IndentChars = "  "
                }))
                {
                    report.WriteTo(writer);
                };
                result.Position = 0;
                return(result);
            }
            else
            {
                return(file.OpenRead());
            }
        }
Пример #2
0
 public static PackageMetadataProvider FromFile(string path)
 {
     if (string.Equals(System.IO.Path.GetExtension(path), ".mf", StringComparison.OrdinalIgnoreCase))
     {
         return(FromPackage(new ManifestFolder(path)));
     }
     else
     {
         return(FromPackage(InnovatorPackage.Load(path)));
     }
 }
Пример #3
0
        public static PackageMetadataProvider FromPackage(InnovatorPackage package)
        {
            var script   = package.Read();
            var metadata = new PackageMetadataProvider()
            {
                Title = script.Title
            };

            metadata.AddRange(script.Lines
                              .Where(l => l.Type != InstallType.DependencyCheck &&
                                     l.Type != InstallType.Warning)
                              .Select(l => ElementFactory.Local.FromXml(l.Script).AssertItem()));
            return(metadata);
        }