Esempio n. 1
0
 /// @brief Add a plugin of the container, given a plugin & versionated member type.
 /// @pre The plugin was revised on requirement for mandatory members (using
 /// PluginVersioning.MandatoryMembersDefined() static method) before call this method.
 /// @param[in] plugin Plugin to reference.
 /// @param[in] MemType Type of member.
 /// @exception VersioningPluginException Problems encountered as versionated member not
 /// valid for the member type, or null plugin.
 public void Add(PluginBase plugin, PluginVersioning.memberType MemType)
 {
     try {
         VersionatedContainer cont = new VersionatedContainer(plugin, MemType);
         if (!cont.IsValidMember())
         {
             throw new VersioningPluginException(
                       "There is no '" + MemType.ToString() + "' defined member in '" +
                       plugin.Name + "' plugin.", plugin);
         }
         else
         {
             this.Add(cont);
         }
     }
     catch (VersioningPluginException e)
     {
         if (e.IsNullPluginBase())
         {
             throw new VersioningPluginException("Plugin reference is NULL, for " + MemType.ToString() + "member type.", e);
         }
         else
         {
             throw e;
         }
     }
 }
Esempio n. 2
0
 /// @brief Default constructor.
 /// @details The constructor determines also the version of the member, from the type class
 /// and the member type parameter, but it is possible that it doesn't have one, as the case
 /// of system plugins (logic probe, cogs windows, etc).
 /// @param[in] plugin Reference to plugin.
 /// @param[in] MemType Type of member to select.
 /// @exception VersioningPluginException Null plugin encountered.
 public VersionatedContainer(PluginBase plugin, PluginVersioning.memberType MemType)
 {
     if (plugin == null)
     {
         throw new VersioningPluginException(
                   "Plugin reference is NULL, for new VersionatedContainer() of \"" +
                   MemType.ToString() + "\" member type.");
     }
     ;
     if (!plugin.IsUserPlugin)
     {
         throw new VersioningPluginException(
                   "Plugin \"" +
                   plugin.Name + "\" is system plugin. Versioning is only allowed to user plugins.");
     }
     else
     {
         _plugin   = plugin;
         _membType = MemType;
         //As theorically a PluginBase descendent can have instanciated more than one version
         //of each memberType, below code detects and returns the higher version available.
         //if there is none avalaible, the return value is false.
         if (_plugin.Versioning.GetImplementedMethod(MemType, out _member))
         {
             _version = _member.VersionLow;
         }
         else
         {
             _version = -1.0f;
         }
     }
 }
Esempio n. 3
0
        /// @brief Get member code by type and version using Reflexion, then and run it with the
        /// supplied parameter list.
        /// @param[in] parms Parameter list to perform the invocation of a versionated member
        public bool Invoke(params PluginVersioning.ParamMemberInfo[] parms)
        {
            if (!this.IsValidMember())
            {
                return(false);
            }
            else
            {
                bool state = false;
                //validate the given parameter list is not empty
                if (parms.Length == 0)
                {
                    return(false);
                }
                else
                {
                    //validate if there are not enough parameters according to memberType
                    if (_plugin.Versioning.ParametersQty(_membType) > parms.Length)
                    {
                        throw new VersioningPluginException(
                                  "There are not enough parameters supplied in plugin \"" + _plugin.Name +
                                  "\" when invoking for \"" + _membType.ToString() + "\" member type. Supplied " +
                                  parms.Length + ", but " + _plugin.Versioning.ParametersQty(_membType) +
                                  "required.");
                    }
                    else
                    {
                        //get the possible parameters for this member type
                        var possibleParamList = _plugin.Versioning.GetPossibleParams(_membType);
                        //traverse the given parameters
                        foreach (PluginVersioning.ParamMemberInfo givenParam in parms)
                        {
                            Type correspType;
                            //check if this given parameter exists in the possibles parameter list
                            if (!possibleParamList.TryGetValue(givenParam.Name, out correspType))
                            {
                                throw new VersioningPluginException(
                                          "Given parameter \"" + givenParam.ParameterObj.GetType().ToString() +
                                          " " + givenParam.Name +
                                          "\" not found in the possibles parameter list for \"" +
                                          _membType.ToString() + "\" member type in plugin \"" + _plugin.Name +
                                          "\".");
                            }
                            //check if the given parameter is compatible (name & type) with the possible one
                            if (!givenParam.IsCompatible(givenParam.Name, correspType))
                            {
                                throw new VersioningPluginException(
                                          "Given parameter \"" + givenParam.ParameterObj.GetType().ToString() +
                                          " " + givenParam.Name +
                                          "\" not matched with the possibles parameter list for \"" +
                                          _membType.ToString() + "\" member type in plugin \"" + _plugin.Name +
                                          "\".");
                            }
                            //
                            //TODO [ASB] : determinar el orden de los parametros a entregar a la llamada
                            _member.ParamListOfMethod
                        }

                        // TODO [ASB] : agregar lógica para invocar el método (nombre: _member.MInfo.Name)



                        state = true;
                    }
                    return(state);
                }
            }
        }