/// <summary> /// Gets rules from /config/autoNode.config file (if it exists) /// </summary> private void GetRulesFromConfigFile() { XmlDocument xmlConfig = new XmlDocument(); try { xmlConfig.Load(HostingEnvironment.MapPath(GlobalSettings.Path + "/../config/DotSee.Elv.config")); } catch (FileNotFoundException ex) { Umbraco.Core.Logging.LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Elv: Configuration file was not found.", ex); return; } catch (Exception ex) { Umbraco.Core.Logging.LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Elv: There was a problem loading Elv configuration from the config file", ex); return; } Umbraco.Core.Logging.LogHelper.Info(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Elv: Loading configuration..."); Indexer = xmlConfig.SelectSingleNode("/elv").Attributes["indexer"].Value; foreach (XmlNode xmlConfigEntry in xmlConfig.SelectNodes("/elv/rule")) { if (xmlConfigEntry.NodeType == XmlNodeType.Element) { string docTypeAlias = xmlConfigEntry.Attributes["docTypeAlias"].Value; string propertyAlias = xmlConfigEntry.Attributes["propertyAlias"].Value; var rule = new ElvRule(docTypeAlias, propertyAlias); _rules.Add(rule); } } Umbraco.Core.Logging.LogHelper.Info(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Elv: Loading configuration complete"); }
/// <summary> /// Registers a new rule object /// </summary> /// <param name="rule">The rule object</param> public void RegisterRule(ElvRule rule) { _rules.Add(rule); }