public static void Initialize(Resources resources) { const string sectionName = UrlsConfiguration.SectionName; var routingConfiguration = ConfigurationServices.ConfigurationSource.GetSection(sectionName) as UrlsConfiguration; Verify.IsNotNull(routingConfiguration, "Config section '{0}' is missing", sectionName); var factory = new UrlFormatterFactory(); var formatters = new List <Tuple <IUrlFormatter, bool> >(); var urlFormattersConfigNode = routingConfiguration.UrlFormatters; if (urlFormattersConfigNode != null) { foreach (var urlFormatterData in urlFormattersConfigNode) { string name = urlFormatterData.Name; try { formatters.Add(new Tuple <IUrlFormatter, bool>(factory.Create(name), urlFormatterData.Mandatory)); } catch (Exception ex) { Log.LogError(LogTitle, "Failed to load url formatter '{0}'", name); Log.LogError(LogTitle, ex); } } } resources.UrlFormatters = formatters; }
public static void Initialize(Resources resources) { const string sectionName = UrlsConfiguration.SectionName; var routingConfiguration = ConfigurationServices.ConfigurationSource.GetSection(sectionName) as UrlsConfiguration; Verify.IsNotNull(routingConfiguration, "Config section '{0}' is missing", sectionName); var factory = new UrlFormatterFactory(); var formatters = new List<Tuple<IUrlFormatter, bool>>(); var urlFormattersConfigNode = routingConfiguration.UrlFormatters; if (urlFormattersConfigNode != null) { foreach (var urlFormatterData in urlFormattersConfigNode) { string name = urlFormatterData.Name; try { formatters.Add(new Tuple<IUrlFormatter, bool>(factory.Create(name), urlFormatterData.Mandatory)); } catch(Exception ex) { Log.LogError(LogTitle, "Failed to load url formatter '{0}'", name); Log.LogError(LogTitle, ex); } } } resources.UrlFormatters = formatters; }