• 0

[C#] Extending API's


Question

I was just wondering... if i have a program that interacts with plugins how can i extend the functionality of the plugin API without breaking compatability.

Just say the API initially has 2 methods that every plugin can call and i build 10 plugins that implement this interface... how can i add new methods to the API that newer plugins can use without breaking compatability with the older plugins? (seen that them dont implement the API interface).

Not a major concern at the moment, but i'd like to know at the same time just incase i run into this problem in the future.

Would I need to have a few API versions?

Thanks guys...

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

+1 for the above.

GE

		private List<string> FindAllClasses(string fileAddress)
		{

			var classList = new List<string>();

			try
			{

				var assembly = Assembly.LoadFile(fileAddress);

				classList = (from t in assembly.GetTypes()
							 where t.IsClass && typeof(IyourInterfaceType).IsAssignableFrom(t)
							 select t.Name).ToList();

			}
			catch (Exception ex)
			{
				// Log / Do something...
				return classList;
			}

			return classList;

		}

Here's something for you....this will return a list of the class names within an assembly where the class name implements the interface you specify. Replace "IyourInterfaceType" with your Interface Type.

GE

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.