private Dictionary <string, string> GetOptions(IDictionary <string, string> options) { var coalescedOptions = new Dictionary <string, string>(ConfigurableOptions.ToDictionary(k => k.OptionName, v => v.Default)); foreach (var item in options) { coalescedOptions[item.Key] = item.Value; } return(coalescedOptions); }
/// <summary> /// Validate that the settings provided in a given pointer are valid /// </summary> /// <param name="pointer">Plugin pointer to validate</param> /// <returns></returns> public bool Validate(PluginPointerModel pointer) { var coalescedOptions = GetOptions(pointer.PluginParameters); if (ConfigurableOptions.Any(o => o.Required && (!coalescedOptions.ContainsKey(o.OptionName) || string.IsNullOrEmpty(coalescedOptions[o.OptionName])))) { Logger.LogCritical("One or more required configuration elements are missing!"); return(false); } if (ValidResourceTypes == null && pointer.Resource != null) { Logger.LogCritical("Plugin does not take any Resource inputs"); return(false); } if (pointer.Resource != null) { var targetResource = ResourceManager.Instance.GetByPointer(pointer.Resource); // Check if this resolves if (targetResource == null) { Logger.LogCritical("Resource {0} does not resolve", pointer.Resource.ResourceId); return(false); } if (!ValidResourceTypes.Any(t => t.IsInstanceOfType(targetResource))) { Logger.LogCritical("One or more resources are not supported by plugin"); return(false); } } return(true); }