Represents a ServiceElement configuration element within the configuration.
Inheritance: System.Configuration.ConfigurationElement
        /// <summary>
        /// Returns the <see cref="SettingElementCollection"/> for the given plugin.
        /// Override the settings using appSettings using the following format "ImageProcessor.&lt;PluginName&gt;.&lt;settingKey&gt; e.g. 'ImageProcessor.CloudImageService.Host'. The key must exist in the config section for the appsetting to apply"
        /// </summary>
        /// <param name="name">
        /// The name of the plugin to get the settings for.
        /// </param>
        /// <returns>
        /// The <see cref="SettingElementCollection"/> for the given plugin.
        /// </returns>
        private Dictionary <string, string> GetServiceSettings(string name)
        {
            ImageSecuritySection.ServiceElement serviceElement = this.GetImageSecuritySection()
                                                                 .ImageServices
                                                                 .Cast <ImageSecuritySection.ServiceElement>()
                                                                 .FirstOrDefault(x => x.Name == name);

            Dictionary <string, string> settings;

            if (serviceElement != null)
            {
                settings = serviceElement.Settings
                           .Cast <SettingElement>()
                           .ToDictionary(setting => setting.Key, setting => setting.Value);

                // Override the config section settings with values found in the app.config / deployment slot settings
                this.OverrideDefaultSettingsWithAppSettingsValue(settings, name);
            }
            else
            {
                settings = new Dictionary <string, string>();
            }

            return(settings);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the whitelist of <see cref="System.Uri"/> for the given service.
        /// </summary>
        /// <param name="name">
        /// The name of the service to return the whitelist for.
        /// </param>
        /// <returns>
        /// The <see cref="System.Uri"/> array containing the whitelist.
        /// </returns>
        private Uri[] GetServiceWhitelist(string name)
        {
            ImageSecuritySection.ServiceElement serviceElement = this.GetImageSecuritySection()
                                                                 .ImageServices
                                                                 .Cast <ImageSecuritySection.ServiceElement>()
                                                                 .FirstOrDefault(x => x.Name == name);

            Uri[] whitelist = { };
            if (serviceElement != null)
            {
                whitelist = serviceElement.WhiteList.Cast <ImageSecuritySection.SafeUrl>()
                            .Select(s => s.Url).ToArray();
            }

            return(whitelist);
        }
Beispiel #3
0
        /// <summary>
        /// Returns the <see cref="SettingElementCollection"/> for the given plugin.
        /// </summary>
        /// <param name="name">
        /// The name of the plugin to get the settings for.
        /// </param>
        /// <returns>
        /// The <see cref="SettingElementCollection"/> for the given plugin.
        /// </returns>
        private Dictionary <string, string> GetServiceSettings(string name)
        {
            ImageSecuritySection.ServiceElement serviceElement = this.GetImageSecuritySection()
                                                                 .ImageServices
                                                                 .Cast <ImageSecuritySection.ServiceElement>()
                                                                 .FirstOrDefault(x => x.Name == name);

            Dictionary <string, string> settings;

            if (serviceElement != null)
            {
                settings = serviceElement.Settings
                           .Cast <SettingElement>()
                           .ToDictionary(setting => setting.Key, setting => setting.Value);
            }
            else
            {
                settings = new Dictionary <string, string>();
            }

            return(settings);
        }