44
55namespace Simplify . Web . Modules . Data ;
66
7+ /// <summary>
8+ /// Provides the data collector.
9+ /// </summary>
10+ /// <seealso cref="IDataCollector" />
711public class DataCollector ( string mainContentVariableName , string titleVariableName , IStringTable stringTable ) : IDataCollector
812{
13+ /// <summary>
14+ /// Gets the name of the title variable.
15+ /// </summary>
16+ /// <value>
17+ /// The name of the title variable.
18+ /// </value>
919 public string TitleVariableName { get ; } = titleVariableName ;
1020
21+ /// <summary>
22+ /// Gets a data collector items which will be inserted into master template file.
23+ /// </summary>
24+ /// <value>
25+ /// The items.
26+ /// </value>
1127 public IDictionary < string , string > Items { get ; } = new Dictionary < string , string > ( ) ;
1228
29+ /// <summary>
30+ /// Gets the <see cref="string"/> with the specified key.
31+ /// </summary>
32+ /// <value>
33+ /// The <see cref="string"/>.
34+ /// </value>
35+ /// <param name="key">The key.</param>
1336 public string this [ string key ] => Items [ key ] ;
1437
38+ /// <summary>
39+ /// Set the template variable value (all occurrences will be replaced).
40+ /// </summary>
41+ /// <param name="variableName">Variable name in master template file.</param>
42+ /// <param name="value">Value to set.</param>
43+ /// <exception cref="ArgumentException">Value cannot be null or empty. - variableName</exception>
1544 public void Add ( string ? variableName , string ? value )
1645 {
1746 if ( string . IsNullOrEmpty ( variableName ) )
@@ -28,6 +57,11 @@ public void Add(string? variableName, string? value)
2857 Items [ variableName ! ] += value ;
2958 }
3059
60+ /// <summary>
61+ /// Set the template variable value with a data from template (all occurrences will be replaced).
62+ /// </summary>
63+ /// <param name="variableName">Variable name in master template file.</param>
64+ /// <param name="template">The template.</param>
3165 public void Add ( string variableName , ITemplate ? template )
3266 {
3367 if ( template == null )
@@ -36,17 +70,49 @@ public void Add(string variableName, ITemplate? template)
3670 Add ( variableName , template . Get ( ) ) ;
3771 }
3872
73+ /// <summary>
74+ /// Set the template main content variable value (all occurrences will be replaced).
75+ /// </summary>
76+ /// <param name="value">Value to set.</param>
3977 public void Add ( string ? value ) => Add ( mainContentVariableName , value ) ;
4078
79+ /// <summary>
80+ /// Set the template main content variable value with a data from template (all occurrences will be replaced).
81+ /// </summary>
82+ /// <param name="template">The template.</param>
4183 public void Add ( ITemplate template ) => Add ( mainContentVariableName , template ) ;
4284
85+ /// <summary>
86+ /// Set the template title variable value (all occurrences will be replaced).
87+ /// </summary>
88+ /// <param name="value">Value to set.</param>
4389 public void AddTitle ( string ? value ) => Add ( TitleVariableName , value ) ;
4490
91+ /// <summary>
92+ /// Set the template variable value from StringTable (all occurrences will be replaced).
93+ /// </summary>
94+ /// <param name="variableName">Variable name in master template file.</param>
95+ /// <param name="stringTableKey">StringTable key.</param>
4596 public void AddSt ( string variableName , string stringTableKey ) => Add ( variableName , stringTable . GetItem ( stringTableKey ) ) ;
4697
98+ /// <summary>
99+ /// Set the template main content variable value from StringTable (all occurrences will be replaced).
100+ /// </summary>
101+ /// <param name="stringTableKey">StringTable key.</param>
47102 public void AddSt ( string stringTableKey ) => Add ( stringTable . GetItem ( stringTableKey ) ) ;
48103
104+ /// <summary>
105+ /// Set the template title variable value from StringTable (all occurrences will be replaced).
106+ /// </summary>
107+ /// <param name="stringTableKey">StringTable key.</param>
49108 public void AddTitleSt ( string stringTableKey ) => AddTitle ( stringTable . GetItem ( stringTableKey ) ) ;
50109
110+ /// <summary>
111+ /// Checking if some variable data is already exist in a data collector.
112+ /// </summary>
113+ /// <param name="variableName">Variable name.</param>
114+ /// <returns>
115+ /// <c>true</c> if the variable name exists; otherwise, <c>false</c>.
116+ /// </returns>
51117 public bool IsDataExist ( string variableName ) => Items . ContainsKey ( variableName ) ;
52118}
0 commit comments