一般来说插件的用途是什么 [英] What is the use of plugin in general

查看:96
本文介绍了一般来说插件的用途是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i对插件的一般术语有疑问..

ya我在网上搜索过它,得到点像它是一个为现有应用程序添加额外功能的程序..



但我无法理解清楚..



可以用任何一个实际解释它吗?

Hi all,

i have doubt in general term of plugins..
ya i searched about it in net, got point like its a program that add extra features to existing application..

but i couldnt understood clearly ..

can any one explain it with practially?

推荐答案

是的,添加功能。重要的一点是:主机应用程序是由一方开发的,但有些插件可以由其他人开发,例如用户或第三方。



我不知道为何解释用途。这不是很明显吗?它几乎可以在任何地方使用。你知道浏览器插件吗?现在,看一些高级文本编辑器。插件可以为特定的编程语言提供语法着色,调用编译器,以适合该语言的方式呈现编译结果。对每种特定语言的支持可以是单独的插件,或者一个插件可以包含多个实现,例如,对于一组语言。主机应用程序不必是UI应用程序。它可以是一个仅限控制台的应用程序,服务,甚至是一个驱动程序。



从.NET的角度来看,插件模型非常有趣。主机应用程序应定义一些或多个接口,以便由某些插件实现。我将称之为插件接口。这是一直需要的东西。在某些情况下,主机应用程序本身需要为插件实现提供一些接口。例如,在编辑器的情况下,该应用程序应该提供一些接口并实现它,以便为插件提供一些编辑缓冲区的访问权限;这样,插件可以读取用户输入的文本或生成一些文本。生成什么只知道插件代码,调用接口方法,以及如何将生成的文本插入编辑缓冲区只对实现此主机接口的主机应用程序已知。



使用接口(接口,而不是它们的实现)的定义进行编译非常有趣。通常,您定义一些程序集,并在那里定义接口。主程序和插件都引用了此程序集。人们不太了解可以直接在主机应用程序中定义所有内容。插件也可以引用此应用程序的程序集。这里没有循环依赖:插件的编译取决于主机应用程序组装,但是在运行时使用Reflection加载插件。



我分享了很多我在过去的答案中详细介绍了插件架构和实现的开发:

AppDomain拒绝加载程序集 [ ^ ],

代码生成 [ ^ ],

创建WPF应用程序使用可重新加载的插件... [ ^ ],

动态加载用户控件 [ ^ ],

现有实例的C#Reflection InvokeMember [ ^ ],

项目和DLL':如何保持它们可管理? [ ^ ],

http://www.codeproject.com / Answers / 443680 / Gathering-types-from-assemblies-by-string-repr#answer1 [ ^ ]。



这个是非常有趣的东西;请看看。



-SA
Yes, to add features. On of the important point is: the host application is developed by one party, but some plug-ins can be developed by others, such as users or 3rd-parties.

I don''t know why explaining the uses. Isn''t that obvious? It can be used nearly anywhere. Do you know the Browser plug-ins? Now, look at some advanced text editor. A plug-in can provide syntax coloring for a particular programming language, invoke a compiler, present compilation results in a way adequate for this language. A support for every particular language can be a separate plug-in, or one plug-in can contain several implementations, for example, for a set of languages. A host application does not have to be a UI application. It can be a console-only application, service, even a driver.

From the standpoint of .NET, the plug-in model is pretty interesting. A host application should define one or more interfaces to be implemented by some plug-ins. I will call them plug-in interfaces. This is something which always needed. In some cases, the host application itself needs to provide some interface to the plug-in implementations. For example, in case of the editor, this application should provide some interface, and implemented it, to give plug-in some access to edit buffer; this way, the plug-in could read text entered by the user or generate some text. What to generate "knows" just the plug-in code, calls interface methods, and how to insert the generated text into the edit buffer is "known" only to the host application which implements this host interface.

Compilation with the definition of interfaces (interfaces, not their implementations) is pretty interesting. Usually, you define some assembly, and define interfaces there. This assembly is referenced by both host application and plug-ins. Less people understand that it''s possible to define everything directly in the host application. The assembly of this application can be referenced by plug-ins just as well. There is no circular dependency here: compilation of plug-ins depends on host application assembly, but plug-ins are loaded during run time using Reflection.

I shared a lot of detail on development of plug-in architectures and implementation in my past answers:
AppDomain refuses to load an assembly[^],
code generating using CodeDom[^],
Create WPF Application that uses Reloadable Plugins...[^],
Dynamically Load User Controls[^],
C# Reflection InvokeMember on existing instance[^],
Projects and DLL''s: How to keep them managable?[^],
http://www.codeproject.com/Answers/443680/Gathering-types-from-assemblies-by-its-string-repr#answer1[^].

This is pretty interesting stuff; please take a look.

—SA


一个非常实用的例子就是插件PhotoShop或其他图形程序。



应用程序提供基本功能,但其他开发人员可以编写扩展该功能的插件 - 添加不同的过滤器,效果等。 />


正如你在标签中提到jQuery一样,jQuery是另一个很好的例子。虽然它提供了许多功能(这些功能本质上是javascript功能的简称),但是其他人可以编写与jQuery一起使用的插件来提供额外的功能 - 例如不同的动画效果,控件等。
A very practical example would be plug ins for PhotoShop or other graphics programs.

The application gives the essential functionality, but other developers can write plug ins that extends that functionality - adding different filters, effects etc.

As you mention jQuery in your tags, jQuery is another good example. While it provides a number of functions (which are essentially short cuts to javascript functionality) others can write plug ins that work with jQuery to provide additional functionality - such as different animation effects, controls etc.


这篇关于一般来说插件的用途是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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