/// <summary> /// Parse any command line properties, allowing them /// to override the file base ones /// </summary> /// <param name="context">Preprocessing context</param> /// <param name="array">ArrayList read from command line</param> public void AddPropertiesFromArrayList(PreprocessingContext context, ArrayList array) { for (int i = 0; i < array.Count; i++) { string property = (string)array[i]; if (null != property && property.Length > 0) { string propertyName = null; string propertyValue = ""; int equalPos = -1; if (context.IsDynamicProperty(property)) { equalPos = property.LastIndexOf('='); } else { equalPos = property.IndexOf('='); } if (-1 == equalPos) { propertyName = property; } else { propertyName = property.Substring(0, equalPos); propertyValue = property.Substring(equalPos + 1); } Add(propertyName, propertyValue); } } }
/// <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); }