当前位置: 首页 > news >正文

建网站前途/seo网站外链工具

建网站前途,seo网站外链工具,太原网站制作开发,关于一学一做的短视频网站好一手资料来源于“开放工厂”,以下程序将会引用到一个核心文件UIShell.OSGi.dll 目前我对于OSGi这个框架的理解就是,主程序搜索并加载插件,以插件方式开放,便于扩展。 现在开始正式的旅程。 首先新建一个C#控制台应用程序(.NET 4.0…

一手资料来源于“开放工厂”,以下程序将会引用到一个核心文件UIShell.OSGi.dll

目前我对于OSGi这个框架的理解就是,主程序搜索并加载插件,以插件方式开放,便于扩展。

 

现在开始正式的旅程。

首先新建一个C#控制台应用程序(.NET 4.0)按照惯例取名HelloWorld

添加OSGi.NET的引用(上述dll文件),设置输出目录为bin(建议这样做)

这个程序的主函数(Main)中只做一件事,就是启动插件框架,完整代码如下

 

[csharp] view plaincopy
print?在CODE上查看代码片派生到我的代码片
  1. using System;  
  2. using UIShell.OSGi;  
  3.   
  4. namespace OSGi.HelloWorld  
  5. {  
  6.     class Program  
  7.     {  
  8.         static void Main(string[] args)  
  9.         {  
  10.             using(BundleRuntime bdrt=new BundleRuntime())  
  11.             {  
  12.                 Console.WriteLine("Start bundle...");  
  13.                 bdrt.Start();  
  14.                 bdrt.Stop();  
  15.                 Console.WriteLine("Press any key to continue...");  
  16.                 Console.ReadKey();  
  17.             }  
  18.         }  
  19.     }  
  20. }  
using System;
using UIShell.OSGi;namespace OSGi.HelloWorld
{class Program{static void Main(string[] args){using(BundleRuntime bdrt=new BundleRuntime()){Console.WriteLine("Start bundle...");bdrt.Start();bdrt.Stop();Console.WriteLine("Press any key to continue...");Console.ReadKey();}}}
}

现在,我们的各项功能可以通过插件扩展实现。

 

给两个示例吧,一个是打印消息,一个是弹出消息框,都很简单。

编写插件需要输出为dll形式,因此我们选择新建Class(类库),同样要添加OSGi.NET的引用

 

两个类的代码分别如下

 

[csharp] view plaincopy
print?在CODE上查看代码片派生到我的代码片
  1. using System;  
  2. using UIShell.OSGi;  
  3.   
  4. namespace PrintMessagePlugin  
  5. {  
  6.     public class PrintMessage:IBundleActivator  
  7.     {  
  8.         public void Start(IBundleContext context)  
  9.         {  
  10.             Console.WriteLine("<Start> Hello World  -- PrintMessage");  
  11.         }  
  12.   
  13.         public void Stop(IBundleContext context)  
  14.         {  
  15.             Console.WriteLine("<Stop> See you next time. -- PrintMessage");  
  16.         }  
  17.   
  18.     }  
  19. }  
using System;
using UIShell.OSGi;namespace PrintMessagePlugin
{public class PrintMessage:IBundleActivator{public void Start(IBundleContext context){Console.WriteLine("<Start> Hello World  -- PrintMessage");}public void Stop(IBundleContext context){Console.WriteLine("<Stop> See you next time. -- PrintMessage");}}
}

 

输出PrintMessage.dll

 


[csharp] view plaincopy
print?在CODE上查看代码片派生到我的代码片
  1. using System.Windows.Forms;  
  2. using UIShell.OSGi;  
  3.   
  4. namespace PopupMsgBoxPlugin  
  5. {  
  6.     public class PopupMsgBox:IBundleActivator  
  7.     {  
  8.         public void Start(IBundleContext context)  
  9.         {  
  10.            MessageBox.Show("<Start> Hello World!","MsgBox");  
  11.         }  
  12.   
  13.         public void Stop(IBundleContext context)  
  14.         {  
  15.             MessageBox.Show("<Stop> See you.","MsgBox");  
  16.         }  
  17.     }  
  18. }  
using System.Windows.Forms;
using UIShell.OSGi;namespace PopupMsgBoxPlugin
{public class PopupMsgBox:IBundleActivator{public void Start(IBundleContext context){MessageBox.Show("<Start> Hello World!","MsgBox");}public void Stop(IBundleContext context){MessageBox.Show("<Stop> See you.","MsgBox");}}
}
输出PopupmsgBox.dll

 

为了能让主程序搜索并识别插件信息,我们需要添加清单文件

方法之一是 【项目(右键)】-->【添加(新建项...)】-->【数据(XML文件)】

将*.xml命名为manifest.xml然后根据类库代码编写内容,分别如下

PrintMessage的manifest.xml

 

[html] view plaincopy
print?在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="utf-8" ?>  
  2. <Bundle xmlns="urn:uiosp-bundle-manifest-2.0"  
  3.         SymbolicName="PrintMessagePlugin"  
  4.         Name="PrintMessagePlugin"  
  5.         Version="1.0.0.0"  
  6.         InitializedState="Active" >  
  7.   <Activator Type="PrintMessagePlugin.PrintMessage" />  
  8.   <Runtime>  
  9.     <Assembly Path="PrintMessage.dll" />  
  10.   </Runtime>  
  11. </Bundle>  
<?xml version="1.0" encoding="utf-8" ?>
<Bundle xmlns="urn:uiosp-bundle-manifest-2.0"SymbolicName="PrintMessagePlugin"Name="PrintMessagePlugin"Version="1.0.0.0"InitializedState="Active" ><Activator Type="PrintMessagePlugin.PrintMessage" /><Runtime><Assembly Path="PrintMessage.dll" /></Runtime>
</Bundle>

 

 

PopupMsgBox的manifest.xml
[html] view plaincopy
print?在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="utf-8" ?>  
  2. <Bundle xmlns="urn:uiosp-bundle-manifest-2.0"  
  3.         SymbolicName="PopupMesgBoxPlugin"  
  4.         Name="PopupMsgBoxPlugin"  
  5.         Version="1.0.0.0"  
  6.         InitializedState="Active" >  
  7.   <Activator Type="PopupMsgBoxPlugin.PopupMsgBox" />  
  8.   <Runtime>  
  9.     <Assembly Path="PopupMsgBox.dll" />  
  10.   </Runtime>  
  11. </Bundle>  
<?xml version="1.0" encoding="utf-8" ?>
<Bundle xmlns="urn:uiosp-bundle-manifest-2.0"SymbolicName="PopupMesgBoxPlugin"Name="PopupMsgBoxPlugin"Version="1.0.0.0"InitializedState="Active" ><Activator Type="PopupMsgBoxPlugin.PopupMsgBox" /><Runtime><Assembly Path="PopupMsgBox.dll" /></Runtime>
</Bundle>

然后将生成的*.dll及对应的*.xml清单拷贝到HelloWorld主程序对应的bin/Plugins目录(没有请新建)

其中bin就是HelloWorld主程序的exe输出目录

这是bin目录下的内容


这是bin/Plugins目录下的内容

这两个文件夹下的内容如下

 

执行主程序HelloWorld,运行结果如下

 

本文原创,转载请注明出处

http://blog.csdn.net/fengyhack/article/details/40508635

转载于:https://www.cnblogs.com/lvdongjie/p/5548530.html

http://www.jmfq.cn/news/4739023.html

相关文章:

  • 苏州晶体公司网站/个人免费开发网站
  • 去大连需要下载哪些软件/搜索引擎排名优化
  • 我的世界做圆网站/seo综合查询工具下载
  • 可以用AI做网站上的图吗/百度云app
  • 提供温州手机网站制作多少钱/北京互联网公司排名
  • 在线酒店预定网站制作/企业seo网站营销推广
  • 武汉武昌做网站推广/百度搜索技巧
  • 陇西 网站开发/全球最牛的搜索引擎
  • 如何建单页网站/黄页推广引流
  • 甘肃 政府网站信息内容建设/免费发广告的网站大全
  • 狮山做网站/百度电话客服
  • 怎么做国内外网站/网络推广员工资多少钱
  • 做网站网络公司/罗湖区seo排名
  • wordpress nginx伪静态规则/网站优化助手
  • 做系统网站信息检索网站/南宁seo外包要求
  • 企业网络解决方案/重庆百度推广排名优化
  • 宁夏中卫市林业生态建设局网站/搜索引擎优化的重要性
  • 营销型网站建设总结/怎样制作网站教程
  • 刚创业 建网站/百度开户推广
  • 宁波网站设计推广服务公司/十大接单平台
  • 婚纱摄影网站模板源码/班级优化大师免费下载
  • 小型b2c网站建设费用/企业网站建设方案策划
  • 如何注册api key域名/建站优化推广
  • 和外国人做古玩生意的网站/电商seo名词解释
  • 深圳自适应网站开发公司/网站建站教程
  • 亿级别网站开发注意/关键词优化一年的收费标准
  • 会员充值网站怎么做/信息流广告加盟代理
  • 双语言网站源码/aso优化运营
  • 成营销型网站制作/推广网站都有哪些
  • 重庆网站建设与推广/站长工具的使用seo综合查询排名