如何开始创建的.NET应用程序的API [英] How to start creating an application API in .NET

查看:160
本文介绍了如何开始创建的.NET应用程序的API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我工作的公司,我们在.NET开发的桌面应用程序,我们想开了一些地方为其他软件开发商。

In the company I work for we have a desktop application developed in .NET that we like to open up some parts for other software developers.

我看它像某种其他软件可以访问公共方法。有没有标准的方法,最佳做法或这其他的经验?

I see it like some kind of public methods that other software can access. Is there any standard approach, best practices or other experience of this?

我想你可以做到这一点与Win32调用,C / C ++编程等,但我主要是一个.NET开发人员,有一定的多年经验写频的主要VB.NET但也有一些C#。我希望找到一种方法,在.NET中做到这一点。但它应该是在其他语言开发的软件进行访问。

I guess you could do this with Win32 calls, C/C++ programming etc. But I'm mainly a .NET developer and have some years of experience programmming in mainly VB.NET but also some C#. I hope finding a way to do this within .NET. But it should be accessible for software developed in other languages.

最好的问候/ 马格努斯

Best regards/ Magnus

推荐答案

有两种方式来进行此事。第一个涉及使用插入式/模块模式。 从这里开始了解这一点。

There are two ways to go about this. The first involves using the Plug In / Module pattern. Start here for that.

第二种方法是简单地通过有据可查的组件暴露你的API逻辑。

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

你选择的方式真的归结到你想要的实现。例如,Adobe Photoshop中使用该插件图案很大程度上。 MS Office使用这两个插件,以及提供了一个对象的接口与应用程序的工作。

The way you pick really boils down to how you want it implemented. For example, Adobe Photoshop uses the plug-in pattern to great extent. MS Office uses both plug-ins as well as provides an object interface for working with the application.

更新: 在.NET程序集的对象可以简单地通过对象范围设置为公众暴露于外部应用程序使用。这包括Windows表单,业务对象,枚举的,等等。

UPDATE: Objects in .Net assemblies can be exposed to be consumed by external applications simply by setting the objects scope to Public. This includes windows forms, business objects, enum's, etc.

试想一下从外部开发者的角度。将他们所需要的信息有,以便成功地扩展/控制你的产品?不管它是什么,把它的帮助文件中的

Just think about it from the external developer's perspective. What information will they need to have in order to be successful at extending / controlling your product? Whatever that is, put it in the help file.

此外,使用的.Net的自动文档功能。这包括添加XML文档的IDE已经知道如何阅读,并通过智能感知显示。例如:

Also, make use of the auto-documentation features of .Net. This includes adding xml documentation the the IDE already knows how to read and display via 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 ...
}

这篇关于如何开始创建的.NET应用程序的API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆