[runtime] Disable some tests in full-aot mode which cannot be AOTed because of type...
[mono.git] / mcs / class / monodoc / Monodoc / generators / RawGenerator.cs
1 using System;
2 using System.IO;
3 using System.Text;
4 using System.Linq;
5 using System.Collections.Generic;
6
7 using Monodoc;
8
9 namespace Monodoc.Generators
10 {
11         /// <summary>
12         /// This generators returns the raw content of the HelpSource without any transformation
13         /// </summary>
14         public class RawGenerator : IDocGenerator<string>
15         {
16                 public string Generate (HelpSource hs, string id, Dictionary<string, string> context)
17                 {
18                         if (hs == null || string.IsNullOrEmpty (id))
19                                 return null;
20
21                         IEnumerable<string> parts;
22                         if (hs.IsMultiPart (id, out parts))
23                                 return GenerateMultiPart (hs, parts, id, context);
24
25                         if (hs.IsRawContent (id))
26                                 return hs.GetText (id) ?? string.Empty;
27
28                         var result = hs.IsGeneratedContent (id) ? hs.GetCachedText (id) : new StreamReader (hs.GetCachedHelpStream (id)).ReadToEnd ();
29
30                         return result;
31                 }
32
33                 string GenerateMultiPart (HelpSource hs, IEnumerable<string> ids, string originalId, Dictionary<string, string> context)
34                 {
35                         var sb = new StringBuilder ();
36                         foreach (var id in ids)
37                                 sb.AppendLine (Generate (hs, id, context));
38                         return sb.ToString ();
39                 }
40         }
41 }