コード例 #1
0
 /// <summary>
 /// Gets the plugin from the List at index
 /// </summary>
 /// <param name="index">The index of the plugin</param>
 /// <returns>Available Plugin</returns>
 public int GetIndex(Types.AvailableAPI api)
 {
     for (int x = 0; x < this.List.Count; x++)
     {
         if ((this.List  as Types.AvailableAPI) == api)
         {
             return(x);
         }
     }
     return(-1);
 }
コード例 #2
0
ファイル: APIServices.cs プロジェクト: Dnawrkshp/NetCheatPS3
        private void AddAPI(string FileName)
        {
            try
            {
                //Create a new assembly from the plugin file we're adding..
                Assembly apiAssembly = Assembly.LoadFrom(FileName);

                //Next we'll loop through all the Types found in the assembly
                foreach (Type apiType in apiAssembly.GetTypes())
                {
                    if (apiType.IsPublic)        //Only look at public types
                    {
                        if (!apiType.IsAbstract) //Only look at non-abstract types
                        {
                            //Gets a type object of the interface we need the plugins to match
                            Type typeInterface = apiType.GetInterface("NCAppInterface.IAPI", true);

                            //Make sure the interface we want to use actually exists
                            if (typeInterface != null)
                            {
                                //Create a new available plugin since the type implements the IPlugin interface
                                Types.AvailableAPI newAPI = new Types.AvailableAPI();

                                //Set the filename where we found it
                                newAPI.AssemblyPath = FileName;

                                //Create a new instance and store the instance in the collection for later use
                                //We could change this later on to not load an instance.. we have 2 options
                                //1- Make one instance, and use it whenever we need it.. it's always there
                                //2- Don't make an instance, and instead make an instance whenever we use it, then close it
                                //For now we'll just make an instance of all the plugins
                                newAPI.Instance = (IAPI)Activator.CreateInstance(apiAssembly.GetType(apiType.ToString()));


                                //Add the new plugin to our collection here
                                this.colAvailableAPIs.Add(newAPI);

                                //cleanup a bit
                                newAPI = null;
                            }

                            typeInterface = null; //Mr. Clean
                        }
                    }
                }

                apiAssembly = null; //more cleanup
            }
            catch (Exception e)
            {
            }
        }
コード例 #3
0
            /// <summary>
            /// Finds a plugin in the available Plugins
            /// </summary>
            /// <param name="apiNameOrPath">The name or File path of the plugin to find</param>
            /// <returns>Available Plugin, or null if the plugin is not found</returns>
            public Types.AvailableAPI Find(string apiNameOrPath)
            {
                Types.AvailableAPI toReturn = null;

                //Loop through all the plugins
                foreach (Types.AvailableAPI apiOn in this.List)
                {
                    //Find the one with the matching name or filename
                    if ((apiOn.Instance.Name.Equals(apiNameOrPath)) ||
                        apiOn.AssemblyPath.Equals(apiNameOrPath))
                    {
                        toReturn = apiOn;
                        break;
                    }
                }
                return(toReturn);
            }
コード例 #4
0
 /// <summary>
 /// Remove a Plugin to the collection of Available plugins
 /// </summary>
 /// <param name="apiToRemove">The Plugin to Remove</param>
 public void Remove(Types.AvailableAPI apiToRemove)
 {
     this.List.Remove(apiToRemove);
 }
コード例 #5
0
            //A Simple Home-brew class to hold some info about our Available Plugins

            /// <summary>
            /// Add a Plugin to the collection of Available plugins
            /// </summary>
            /// <param name="apiToAdd">The Plugin to Add</param>
            public void Add(Types.AvailableAPI apiToAdd)
            {
                this.List.Add(apiToAdd);
            }