Beispiel #1
0
        /// <summary>
        /// Returns the configuration controller class which is responsible for the specified
        /// <paramref name="setting"/>.
        /// </summary>
        /// <param name="setting">The setting to check.</param>
        /// <returns>Configuration controller class which is responsible for the specified
        /// <paramref name="setting"/>, or <c>null</c>, if the setting is not supported.</returns>
        protected ConfigurationController FindConfigurationController(ConfigSetting setting)
        {
            if (setting == null)
            {
                return(null);
            }
            ConfigurationController result = null;
            // Check if a custom configuration controller is requested
            ConfigSettingMetadata metadata = (ConfigSettingMetadata)setting.Metadata;

            if (metadata.AdditionalTypes != null && metadata.AdditionalTypes.ContainsKey("CustomConfigController"))
            {
                Type controllerType = metadata.AdditionalTypes["CustomConfigController"];
                if (controllerType == null)
                {
                    ServiceRegistration.Get <ILogger>().Warn(
                        "ConfigurationModel: Custom configuration controller could not be loaded (config setting at location '{0}')",
                        metadata.Location);
                    return(null);
                }
                // Check if we already have the required controller available
                foreach (KeyValuePair <Type, ConfigurationController> registration in _registeredSettingTypes)
                {
                    if (registration.Value.GetType() == controllerType)
                    {
                        result = registration.Value;
                        break;
                    }
                }
                if (result == null)
                {
                    // FIXME Albert: Make configuration controllers to models; load them via the workflow manager.
                    // This will make configuration controllers be managed correctly
                    result = Activator.CreateInstance(controllerType) as ConfigurationController;
                    if (result != null)
                    {
                        // Lazily add the new controller type to our registered controllers
                        Register(result);
                    }
                }
                if (result != null)
                {
                    return(result);
                }
            }
            // Check if the workflow configuration controller can handle the setting
            if (_workflowConfigurationController.IsSettingSupported(setting))
            {
                return(_workflowConfigurationController);
            }
            // Else try a default configuration controller
            return(FindConfigurationController(setting.GetType()));
        }
Beispiel #2
0
        /// <summary>
        /// Releases the config object if it is a <see cref="ConfigSetting"/>.
        /// </summary>
        public void DisposeConfigObj()
        {
            IPluginManager pluginManager = ServiceRegistration.Get <IPluginManager>();
            string         itemLocation  = Constants.PLUGINTREE_BASELOCATION + (_parent == null ? string.Empty : _parent.Location);
            ConfigSetting  cs            = _configObj as ConfigSetting;

            if (cs != null)
            {
                PluginItemMetadata pid = pluginManager.GetPluginItemMetadata(itemLocation, Id);
                if (pid == null)
                {
                    return;
                }
                pid.PluginRuntime.RevokePluginObject(cs.GetType().FullName);
            }
        }