/// <summary>
        /// Validate the macros in the collection to ensure they are valid and can be resolved.
        /// </summary>
        private void ValidateMacros()
        {
            if (macroCollection != null)
            {
                ResourceStaticAnalysisConfigMacros macros = new ResourceStaticAnalysisConfigMacros();
                foreach (var macro in macroCollection.Macros)
                {
                    List <String> usedKeys = new List <String>();
                    if (this.ValidateMacro(macro.Name, usedKeys))
                    {
                        macros.Macros.Add(macro);
                    }
                }

                this.macroCollection = macros;
            }
        }
        /// <summary>
        /// Load the ResourceStaticAnalysis Engine Config Macros from the macro definintion file.
        /// </summary>
        /// <remarks>Look first for the macro definition file located on disk in the same location as the executing assembly.
        /// If that isn't found or isn't valid, load the macro definition file embedded as a resource in the assembly.</remarks>
        /// <returns>ResourceStaticAnalysisConfigMacros object loaded from the macro definition file.</returns>
        private ResourceStaticAnalysisConfigMacros LoadConfigMacros()
        {
            Assembly assembly   = Assembly.GetExecutingAssembly();
            String   pathToFile = Path.Combine(Path.GetDirectoryName(new Uri(assembly.CodeBase).LocalPath), macroDefinitionFile);

            ResourceStaticAnalysisConfigMacros macros = null;

            if (!File.Exists(pathToFile) || (macros = ResourceStaticAnalysisConfigMacros.Load(pathToFile)) == null)
            {
                try
                {
                    macros = ResourceStaticAnalysisConfigMacros.Load(assembly.GetManifestResourceStream(String.Format("{0}.{1}", this.GetType().Namespace, macroDefinitionFile)));
                }
                catch
                {
                    //Failed to load the macro file - ignore and move on.
                }
            }

            return(macros ?? new ResourceStaticAnalysisConfigMacros());
        }
 /// <summary>
 /// Creates a new Instance of the ResourceStaticAnalysisConfigMacroHandler class.
 /// </summary>
 private ResourceStaticAnalysisConfigMacroHandler()
 {
     this.macroCollection = this.LoadConfigMacros();
     this.ValidateMacros();
 }