Exemple #1
0
        /// <summary>
        /// Builds a string, joined with the <see cref="Joiner"/> from each of the child <see cref="ILexigram"/> values with the the <paramref name="engine"/>.
        /// </summary>
        /// <param name="engine">The engine to execute code against</param>
        /// <returns>The compiled string from the engine with the composition</returns>
        public virtual string Build(ICompositionEngine engine)
        {
            var built = new StringBuilder();

            foreach (var token in this)
            {
                var value = token.GetValue(engine);
                built.Append(value.ToString());
                if (token is IIdLexigram)
                {
                    var id = (token as IIdLexigram).Id;
                    if (!string.IsNullOrWhiteSpace(id))
                    {
                        engine.SetProperty(id, value);
                    }
                }
            }
            return(string.Join(Joiner, built));
        }