How to start creating an application API in .NET.

At the company I work for, we have a desktop application developed in .NET that we like to open to other software developers.

I see this as some kind of public method that other software can access. Is there any standard approach, best practices or other experiences?

I think you could do this with Win32 calls, C / C ++ programming, etc. But I am mainly a .NET developer and have many years of programming experience mainly in VB.NET, but also in C #. Hope to find a way to do this in .NET. But it must be available for software developed in other languages.

Regards / Magnus

+6
c # api
source share
4 answers

There are two ways around this. The first involves using the Plug In / Module pattern. Start here for this.

The second way is to simply expose your API logic through well-documented assemblies.

The way you choose really comes down to how you want to implement it. For example, Adobe Photoshop uses the plugin template to a large extent. MS Office uses both plug-ins and also provides an object interface for working with the application.

UPDATE: Objects in .Net assemblies can be affected by external applications by simply setting the scope of objects in Public. This includes window forms, business objects, listing, etc.

Think about it from the perspective of an external developer. What information do they need to be successful in expanding / controlling your product? Whatever it is, put it in the help file.

Also, use the features of .Net automatic documentation. This includes adding XML documentation that the IDE already knows how to read and display through intellisense. For example:

/// <summary> /// Gets all active documents for the specified customer. /// </summary> /// <param name="customerId">The Id of the customer.</param> /// <returns>A list of documents for this customer.</returns> public static List<Document> GetDocuments(int customerId) { //... do something ... } 
+6
source share

Create an API class that provides the functions you want to access and register them for the COM project → properties → build → Register for COM interop

+3
source share

"Open application through open API" is not a detailed definition of requirements. Before you develop anything, get detailed requirements.

For the API, I recommend that you start with the requirements and then start using cases. Since this is an API, you have to write code using the proposed API to see how it feels to program it. The code you write should cover your use cases. You can even write this code in unit tests and then create an API through test development and refactoring.

But in any case, since in cases of use the focus is on how the user will use the software, they will help you focus on what parts of the software the user uses directly. One use case may use another; but if the user does not directly use a specific use case, then this is one that should not be published publicly.

Please note that this also helped me in the development of web services. Cases directly accessible by the user are operations that can be viewed through the service. Any use case that the user does not directly call will remain hidden, like an implementation.

+2
source share

Developing a public API is highly dependent on the functionality of your program. If you want to open an API that is available in other languages, XML web services are usually the way to do this. However, this may not be practical for a desktop application only.

0
source share

All Articles