Visual Studio加载项以在.NET中创建Intellisense支持 [英] Visual Studio Add In to Create an Intellisense Support in .NET
问题描述
大家好,
我想为我的图书馆创建自己的智能支持.
示例:
int i = 10;
一世. ?????? (我自己的成员列表)
现在,当我说我.在这里,我需要显示自己的成员列表.
我不知道如何开始.
请阅读讨论以获取更多信息.
请帮助我.
我应该如何进行?
谢谢:)
Hi Guys,
I would like to create my own intellisense support for my library.
Example:
int i = 10;
i. ?????? (My own list of members)
Now, when I say i. here I need my own list of members to be displayed.
I have no idea how to start with.
Please read the discussion for more information.
Please help me with this.
How should I proceed ?
Thank you :)
推荐答案
在我看来,扩展方法可能会有帮助吗?您可以在您的库中为您的自定义(或内置类型)定义它们,然后只需在源文件中通过using
您的库即可将扩展方法显示在Intellisense中,而无需走附加路线.
扩展方法 [
It sounds to me as if extension methods might be of some help? You could define them in your library, for your custom (or built-in types), and then simply byusing
your library in a source file you''d be able to have the extension methods show up in Intellisense, without having to go the Add-in route.
Extension methods[^]
我认为您可以使用扩展方法来实现此功能.自 C#3 [
I think you can achieve this functionality using Extensions method. This functionality is added since C#3[^]. For example, the following class will extend anint
datatype instances to have a functionality called HasValueOtherThanZero.
/// <summary>
/// Integer Extension class
/// </summary>
public static class IntegerExtension
{
/// <summary>
/// Check my number is greater than zero.
/// </summary>
/// <param name="myNumber">MyNumber value</param>
/// <returns>True/False</returns>
public static bool HasValueOtherThanZero(this int myNumber)
{
if (myNumber != null && myNumber > 0)
return true;
return false;
}
}
因此,无论何时实例化一个整数变量,此功能都将出现在."之后.叫.
So when ever you instantiate an integer variable, this functionality will appear after "." called.
static void Main(string[] args)
{
int x = 20;
if (x.HasValueOtherThanZero()) {
// do something
}
}
希望对您有帮助.
I hope this might help you well.
创建类时,其成员将自动由intellisense显示.你没有这种行为吗?
When you create a class its members are displayed by intellisense automatically. Are you not getting this behaviour?
这篇关于Visual Studio加载项以在.NET中创建Intellisense支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!