コード例 #1
0
ファイル: ParametricUtils.cs プロジェクト: phreed/GMac
 /// <summary>
 /// Apply the given parameters values to all templates in this collection and generate text from
 /// each template based on the given parameters. This should be used if all templates use common
 /// or similar set of parameters
 /// </summary>
 /// <param name="composer"></param>
 /// <param name="paramsValues"></param>
 /// <returns></returns>
 public static Dictionary <string, string> GenerateText(this ParametricComposerCollection composer, params object[] paramsValues)
 {
     return
         (composer
          .ToDictionary(
              pair => pair.Key,
              pair => pair.Value.GenerateText(paramsValues)
              ));
 }
コード例 #2
0
        /// <summary>
        /// Create a new ParametricTextBuilderCollection object and add some templates from this object
        /// (by reference) to the new object
        /// </summary>
        /// <param name="templatesNames"></param>
        /// <returns></returns>
        public ParametricComposerCollection SubCollection(IEnumerable <string> templatesNames)
        {
            var subCollection = new ParametricComposerCollection
            {
                _alignMultiLineParameterValues = _ignoreUndefinedParameters,
                _ignoreUndefinedParameters     = _ignoreUndefinedParameters
            };

            foreach (var templateName in templatesNames)
            {
                ParametricComposer template;

                if (
                    ComposersDictionary.TryGetValue(templateName, out template) &&
                    subCollection.ComposersDictionary.ContainsKey(templateName) == false
                    )
                {
                    subCollection.ComposersDictionary.Add(templateName, template);
                }
            }

            return(subCollection);
        }