Ejemplo n.º 1
0
        /// <summary>
        /// Processes the dynamically bound properties.
        /// </summary>
        /// <remarks>
        /// This is a fairly inefficient implementation for the first cut, it would be
        /// nicer if a buffer could be reused to avoid reallocating huge strings for
        /// every single property, especially in the case of XML.
        /// </remarks>
        /// <param name="context">The Preprocessing context.</param>
        /// <param name="content">The content.</param>
        /// <returns>The buffer with any dynamically bound properties replaced</returns>
        private string ProcessDynamicallyBoundProperties(PreprocessingContext context, string content)
        {
            string resultBuffer = content;

            foreach (PreprocessingProperty property in context.Properties)
            {
                if (context.IsDynamicProperty(property.Key))
                {
                    IDynamicResolver resolver = property.GetDynamicResolver(context);
                    if (resolver.ShouldProcess(context.SourceFile))
                    {
                        string replacementValue = ResolveProperties(property.Value, context);
                        resultBuffer = resolver.Replace(resultBuffer, replacementValue);
                    }
                }
            }

            return(resultBuffer);
        }