Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Samples / MonoRail / MRCCnetDashboard / Dashboard.Web / Service / ContentTransformation.cs
blobb8a0cfe3fbb92e68cf88cdfe3246242415b19f97
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Dashboard.Web.Service
17 using System;
18 using System.IO;
19 using System.Xml.XPath;
21 using ThoughtWorks.CruiseControl.Remote;
22 using ThoughtWorks.CruiseControl.Core.Publishers;
25 public enum DetailEnum
27 Summary,
28 Modifications,
29 Compilation,
30 UnitTestsSummary,
31 UnitTestsDetail
35 public class ContentTransformation
37 private readonly ICruiseManager cruiseManager;
38 private readonly IBuildLogTransformer logTransformer;
40 public ContentTransformation(ICruiseManager cruiseManager, IBuildLogTransformer logTransformer)
42 this.logTransformer = logTransformer;
43 this.cruiseManager = cruiseManager;
46 public String GetSummary(String name, String log)
48 String xsl = GetXslFullFileName("header.xsl");
50 String content = cruiseManager.GetLog(name, log);
52 XPathDocument document = new XPathDocument(new StringReader(content));
54 return logTransformer.Transform(document, xsl);
57 public String GetDetail(String name, String log, DetailEnum detail)
59 String xsl = null;
61 if (detail == DetailEnum.Summary)
63 return GetSummary(name, log);
65 else if (detail == DetailEnum.Compilation)
67 xsl = GetXslFullFileName("compile.xsl");
69 else if (detail == DetailEnum.Modifications)
71 xsl = GetXslFullFileName("modifications.xsl");
73 else if (detail == DetailEnum.UnitTestsDetail)
75 xsl = GetXslFullFileName("unittests.xsl");
77 else if (detail == DetailEnum.UnitTestsSummary)
79 xsl = GetXslFullFileName("AlternativeNUnitDetails.xsl");
82 String content = cruiseManager.GetLog(name, log);
84 XPathDocument document = new XPathDocument(new StringReader(content));
86 return logTransformer.Transform(document, xsl);
89 private String GetXslFullFileName(String xslFile)
91 return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "xsl/" + xslFile);