Example #1
0
        public ParameterStack GetParameters(IComponentSearchMethod compSearchMethod)
        {
            ParameterStack parameters = Plugin.Parameters;
            string         grpId      = string.Empty;

            if (null != compSearchMethod)
            {
                foreach (Parameter p in parameters)
                {
                    try
                    {
                        if (p is ParameterAngle pa)
                        {
                            parameters.SetAngleParameter(pa.Name, compSearchMethod.GetAngleParameterDefaultValue(grpId, Guid, pa.Name));
                        }
                        if (p is ParameterDouble pd)
                        {
                            parameters.SetDoubleParameter(pd.Name, compSearchMethod.GetDoubleParameterDefaultValue(grpId, Guid, pd.Name));
                        }
                        if (p is ParameterBool pb)
                        {
                            parameters.SetBoolParameter(pb.Name, compSearchMethod.GetBoolParameterDefaultValue(grpId, Guid, pb.Name));
                        }
                        if (p is ParameterInt pi)
                        {
                            parameters.SetIntegerParameter(pi.Name, compSearchMethod.GetIntParameterDefaultValue(grpId, Guid, pi.Name));
                        }
                        if (p is ParameterMulti pm)
                        {
                            parameters.SetMultiParameter(pm.Name, 0);
                        }
                    }
                    catch (Exception /*ex*/)
                    {
                    }
                }
            }
            return(parameters);
        }
Example #2
0
        public ParameterStack GetParameters(IComponentSearchMethod compSearchMethod)
        {
            ParameterStack parameters = _instance.Parameters;

            if (null != compSearchMethod)
            {
                foreach (Parameter p in parameters)
                {
                    try
                    {
                        ParameterDouble pd = p as ParameterDouble;
                        if (null != pd)
                        {
                            parameters.SetDoubleParameter(pd.Name, compSearchMethod.GetDoubleParameterDefaultValue(Guid, pd.Name));
                        }
                        ParameterBool pb = p as ParameterBool;
                        if (null != pb)
                        {
                            parameters.SetBoolParameter(pb.Name, compSearchMethod.GetBoolParameterDefaultValue(Guid, pb.Name));
                        }
                        ParameterInt pi = p as ParameterInt;
                        if (null != pi)
                        {
                            parameters.SetIntegerParameter(pb.Name, compSearchMethod.GetIntParameterDefaultValue(Guid, pi.Name));
                        }
                        ParameterMulti pm = p as ParameterMulti;
                        if (null != pm)
                        {
                            parameters.SetMultiParameter(pm.Name, 0);
                        }
                    }
                    catch (Exception /*ex*/)
                    {
                    }
                }
            }
            return(parameters);
        }
Example #3
0
        public ParameterStack GetInitializedParameterStack(IPlugin plugin)
        {
            // check if already available in cache
            ParameterStack stack = GetStackFromCache(plugin.Guid);

            if (null == stack)
            {
                if (!(SearchMethod is IComponentSearchMethod))
                {
                    throw new PluginException("Component loader was not initialized with a valid plugin search method.");
                }

                // get parameter stack
                if (plugin is IPluginExt1 pluginExt1)
                {
                    stack = plugin.Parameters;
                }
                else if (plugin is IPluginExt2 pluginExt2)
                {
                    stack = pluginExt2.BuildParameterStack(null);
                }
                else if (plugin is IPluginExt3 pluginExt3)
                {
                    stack = pluginExt3.BuildParameterStack(null);
                }
                else if (plugin is IPluginExt4 pluginExt4)
                {
                    stack = pluginExt4.BuildParameterStack(null);
                }
                // check parameter stack
                if (null == stack)
                {
                    throw new PluginException("Failed to build initial parameter stack.");
                }

                string grpId = string.Empty;

                // load parameter values from plugins
                foreach (Parameter param in stack)
                {
                    try
                    {
                        if (param is ParameterDouble pd)
                        {
                            stack.SetDoubleParameter(pd.Name, SearchMethod.GetDoubleParameterDefaultValue(grpId, plugin.Guid, pd.Name));
                        }
                        if (param is ParameterBool pb)
                        {
                            stack.SetBoolParameter(pb.Name, SearchMethod.GetBoolParameterDefaultValue(grpId, plugin.Guid, pb.Name));
                        }
                        if (param is ParameterInt pi)
                        {
                            stack.SetIntParameter(pi.Name, SearchMethod.GetIntParameterDefaultValue(grpId, plugin.Guid, pi.Name));
                        }
                        if (param is ParameterMulti pm)
                        {
                            stack.SetMultiParameter(pm.Name, SearchMethod.GetMultiParameterDefaultValue(grpId, plugin.Guid, pm.Name));
                        }
                    }
                    catch (Exception /*ex*/)
                    {
                    }
                }
                // save in cache
                InsertParameterStackInCache(plugin.Guid, stack);
            }
            return(stack.Clone());
        }
Example #4
0
        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());
        }