77
88namespace DescribeCompiler
99{
10- public static class Translations
10+ public interface IUnfoldTranslator
11+ {
12+ string TranslateUnfold ( DescribeUnfold u ) ;
13+ }
14+ public class UnfoldTranslator : IUnfoldTranslator
1115 {
1216 static string pageTemplate ;
1317 static string rootTemplate ;
@@ -18,18 +22,18 @@ public static class Translations
1822 static string prodTemplate ;
1923 static string linkTemplate ;
2024
21- static Translations ( )
25+ static UnfoldTranslator ( )
2226 {
23- pageTemplate = ResourceUtil . ExtractResource_String ( @"NotSpacedPage.html " ) ;
24- rootTemplate = ResourceUtil . ExtractResource_String ( @"NotSpacedRoot.html " ) ;
25- prodTemplate = ResourceUtil . ExtractResource_String ( @"NotSpacedProduction.html " ) ;
27+ pageTemplate = ResourceUtil . ExtractResourceByName_String ( @"Page " ) ;
28+ rootTemplate = ResourceUtil . ExtractResourceByName_String ( @"Root " ) ;
29+ prodTemplate = ResourceUtil . ExtractResourceByName_String ( @"Production " ) ;
2630
27- itemTemplate = ResourceUtil . ExtractResource_String ( @"NotSpacedItem.html " ) ;
28- emptyItemTemplate = ResourceUtil . ExtractResource_String ( @"NotSpacedItemEmpty.html " ) ;
29- commentItemTemplate = ResourceUtil . ExtractResource_String ( @"NotSpacedItemComment.html " ) ;
30- coloredItemTemplate = ResourceUtil . ExtractResource_String ( @"NotSpacedItemColored.html " ) ;
31+ itemTemplate = ResourceUtil . ExtractResourceByName_String ( @"Item " ) ;
32+ emptyItemTemplate = ResourceUtil . ExtractResourceByName_String ( @"ItemEmpty " ) ;
33+ commentItemTemplate = ResourceUtil . ExtractResourceByName_String ( @"ItemComment " ) ;
34+ coloredItemTemplate = ResourceUtil . ExtractResourceByName_String ( @"ItemColored " ) ;
3135
32- linkTemplate = ResourceUtil . ExtractResource_String ( @"Link.html " ) ;
36+ linkTemplate = ResourceUtil . ExtractResourceByName_String ( @"Link" ) ;
3337 }
3438
3539 //http://xahlee.info/comp/unicode_circled_numbers.html
@@ -233,7 +237,7 @@ static Translations()
233237 /// </summary>
234238 /// <param name="u">The unfold to be translated</param>
235239 /// <returns>The generated html code</returns>
236- public static string TranslateUnfold ( DescribeUnfold u )
240+ public string TranslateUnfold ( DescribeUnfold u )
237241 {
238242 string data = "" ;
239243 foreach ( string key in u . PrimaryProductions )
@@ -247,12 +251,12 @@ public static string TranslateUnfold(DescribeUnfold u)
247251 return pt ;
248252 }
249253
250- static string TranslateProductionOrItem ( DescribeUnfold u , string id )
254+ string TranslateProductionOrItem ( DescribeUnfold u , string id )
251255 {
252256 if ( u . Productions . ContainsKey ( id ) ) return TranslateProduction ( u , id ) ;
253257 else return TranslateItem ( u , id ) ;
254258 }
255- static string TranslateProduction ( DescribeUnfold u , string id )
259+ string TranslateProduction ( DescribeUnfold u , string id )
256260 {
257261 List < string > li = new List < string > ( ) ;
258262 if ( u . Productions . ContainsKey ( id ) ) li = u . Productions [ id ] ;
@@ -291,7 +295,7 @@ static string TranslateProduction(DescribeUnfold u, string id)
291295 pt = pt . Replace ( "{ITEMS}" , items ) ;
292296 return pt ;
293297 }
294- static string TranslateItem ( DescribeUnfold u , string id )
298+ string TranslateItem ( DescribeUnfold u , string id )
295299 {
296300 //do links
297301 //we are assuming there would be no backslashes in links
0 commit comments