예제 #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
    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 settings = new XmlWriterSettings();
        settings.OmitXmlDeclaration = true;
        settings.Indent = true;
        settings.IndentChars = "  ";
        var result = new MemoryStream();
        using (var writer = XmlWriter.Create(result, settings))
        {
          report.WriteTo(writer);
        };
        result.Position = 0;
        return result;
      }
      else
      {
        return file.OpenRead();
      }

    }
예제 #3
0
 private static string ReadFile(IDiffFile file, Func<string, IDiffFile> fileGetter)
 {
   if (file.Path.EndsWith(".xslt", StringComparison.OrdinalIgnoreCase))
   {
     return InnovatorPackage.ReadReport(file.Path, p => fileGetter(p).OpenRead()).OuterXml;
   }
   else
   {
     using (var baseStream = file.OpenRead())
     using (var baseRead = new StreamReader(baseStream))
     {
       return baseRead.ReadToEnd();
     }
   }
   
 }