public static IisAppPoolConfiguration FromMwaApplicationPool(ILogSink logger, ApplicationPool pool, IisAppPoolConfiguration template = null) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (pool == null) { throw new ArgumentNullException(nameof(pool)); } var config = new IisAppPoolConfiguration(); config.Name = pool.Name; config.Status = (IisObjectState)pool.State; if (template == null) { return(config); } var templateProperties = Persistence.GetPersistentProperties(template.GetType(), false) .Where(p => Attribute.IsDefined(p, typeof(ScriptAliasAttribute))); foreach (var templateProperty in templateProperties) { if (SkipTemplateProperty(template, templateProperty)) { continue; } var mappedProperty = FindMatchingProperty(templateProperty.Name.Split('_'), pool); if (mappedProperty != null) { templateProperty.SetValue(config, mappedProperty.GetValue()); } else { logger.LogWarning($"Matching MWA property \"{templateProperty.Name}\" was not found."); } } return(config); }
public static void SetMwaApplicationPool(ILogSink logger, IisAppPoolConfiguration config, ApplicationPool pool) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (config == null) { throw new ArgumentNullException(nameof(config)); } if (pool == null) { throw new ArgumentNullException(nameof(pool)); } var configProperties = Persistence.GetPersistentProperties(config.GetType(), false) .Where(p => Attribute.IsDefined(p, typeof(ScriptAliasAttribute))); foreach (var configProperty in configProperties) { if (SkipTemplateProperty(config, configProperty)) { continue; } object value = configProperty.GetValue(config); var mappedProperty = FindMatchingProperty(configProperty.Name.Split('_'), pool); if (mappedProperty != null) { mappedProperty.SetValue(value); } else { logger.LogWarning($"Matching MWA property \"{configProperty.Name}\" was not found."); } } }