/// <summary> /// Build parameter stack /// IPluginExt1 simply returns a static list of parameters or the same current list /// IpluginExt2 builds a new list depending on the current list state /// </summary> public ParameterStack BuildParameterStack(ParameterStack stackIn1) { ParameterStack stackIn = (null != stackIn1) ? ConvertIn(stackIn1) : null; ParameterStack stackOut; if (null != _ext1) { if (null != stackIn && stackIn.Count > 0) { stackOut = stackIn; } else { stackOut = Plugin.Parameters; } } else if (null != _ext2) { stackOut = _ext2.BuildParameterStack(stackIn); } else if (null != _ext3) { stackOut = _ext3.BuildParameterStack(stackIn); } else if (null != _ext4) { stackOut = _ext4.BuildParameterStack(stackIn); } else { stackOut = new ParameterStack(); } // adding thickness parameters // these parameters are always available but are not shown in the list of parameters in the plugin viewer // ep1 and th1 are reserved name double defaultThickness = Host.Properties.Settings.Default.Thickness; if (!stackOut.HasParameter("th1")) { stackOut.AddDoubleParameter("th1", "Thickness" , null != stackIn && stackIn.HasParameter("th1") ? stackIn.GetDoubleParameterValue("th1") : defaultThickness); } if (!stackOut.HasParameter("ep1")) { stackOut.AddDoubleParameter("ep1", "Thickness" , null != stackIn && stackIn.HasParameter("ep1") ? stackIn.GetDoubleParameterValue("ep1") : defaultThickness); } return(ConvertOut(stackOut)); }
public ParameterStack GetInitializedParameterStack(IPlugin plugin) { // check if already available in cache ParameterStack stack = null; stack = ComponentLoader.GetStackFromCache(plugin.Guid); if (null == stack) { if (!(_searchMethod is IComponentSearchMethod)) { throw new PluginException("Component loader was not initialized with a valid plugin search method."); } IPluginExt1 pluginExt1 = plugin as IPluginExt1; IPluginExt2 pluginExt2 = plugin as IPluginExt2; IPluginExt3 pluginExt3 = plugin as IPluginExt3; // get parameter stack if (null != pluginExt1) { stack = plugin.Parameters; } else if (null != pluginExt2) { stack = pluginExt2.BuildParameterStack(null); } else if (null != pluginExt3) { stack = pluginExt3.BuildParameterStack(null); } // check parameter stack if (null == stack) { throw new PluginException("Failed to build initial parameter stack."); } // load parameter values from plugins foreach (Parameter param in stack) { try { ParameterDouble pd = param as ParameterDouble; if (null != pd) { stack.SetDoubleParameter(pd.Name, _searchMethod.GetDoubleParameterDefaultValue(plugin.Guid, pd.Name)); } ParameterBool pb = param as ParameterBool; if (null != pb) { stack.SetBoolParameter(pb.Name, _searchMethod.GetBoolParameterDefaultValue(plugin.Guid, pb.Name)); } ParameterInt pi = param as ParameterInt; if (null != pi) { stack.SetIntParameter(pi.Name, _searchMethod.GetIntParameterDefaultValue(plugin.Guid, pi.Name)); } ParameterMulti pm = param as ParameterMulti; if (null != pm) { stack.SetMultiParameter(pm.Name, _searchMethod.GetMultiParameterDefaultValue(plugin.Guid, pm.Name)); } } catch (Exception /*ex*/) { } } // save in cache ComponentLoader.InsertParameterStackInCache(plugin.Guid, stack); } return(stack.Clone()); }