class Program
{
static void Main(string[] args)
{
var container = new WindsorContainer();
container.Install(FromAssembly.This()); var king = container.Resolve<IKing>("King1");
king.SayHello();
var king2 = container.Resolve<IKing>("King2");
king2.SayHello();
Console.Read(); }
}
public class RepositoriesInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
//container.Register(Classes.FromThisAssembly()
// .Where(Component.IsInSameNamespaceAs<King>())
// .WithService.DefaultInterfaces()
// .LifestyleTransient());
//container.Register(Classes.FromThisAssembly()
// .Where(Component.IsInSameNamespaceAs<King2>())
// .WithService.DefaultInterfaces()
// .LifestyleTransient());
container.Register(Component.For(typeof(IKing))
.ImplementedBy(typeof(King1))
.Named("King1").LifestyleTransient());
container.Register(Component.For(typeof (IKing))
.ImplementedBy(typeof (King2))
.Named("King2").LifestyleTransient());
}
} public interface IKing
{
void SayHello();
} public class King1 : IKing
{
public void SayHello()
{
Console.WriteLine("Hello i am the first king1");
}
} public class King2 : IKing
{
public void SayHello()
{
Console.WriteLine("Hello i am the first king2");
}
}

https://github.com/castleproject/Windsor/blob/master/docs/README.md

CastelWindsor Demo的更多相关文章

  1. 通过一个demo了解Redux

    TodoList小demo 效果展示 项目地址 (单向)数据流 数据流是我们的行为与响应的抽象:使用数据流能帮我们明确了行为对应的响应,这和react的状态可预测的思想是不谋而合的. 常见的数据流框架 ...

  2. 很多人很想知道怎么扫一扫二维码就能打开网站,就能添加联系人,就能链接wifi,今天说下这些格式,明天做个demo

    有些功能部分手机不能使用,网站,通讯录,wifi基本上每个手机都可以使用. 在看之前你可以扫一扫下面几个二维码先看看效果: 1.二维码生成 网址 (URL) 包含网址的 二维码生成 是大家平时最常接触 ...

  3. 在线浏览PDF之PDF.JS (附demo)

    平台之大势何人能挡? 带着你的Net飞奔吧!:http://www.cnblogs.com/dunitian/p/4822808.html#skill 下载地址:http://mozilla.gith ...

  4. 【微框架】Maven +SpringBoot 集成 阿里大鱼 短信接口详解与Demo

    Maven+springboot+阿里大于短信验证服务 纠结点:Maven库没有sdk,需要解决 Maven打包找不到相关类,需要解决 ps:最近好久没有写点东西了,项目太紧,今天来一篇 一.本文简介 ...

  5. vue双向数据绑定原理探究(附demo)

    昨天被导师叫去研究了一下vue的双向数据绑定原理...本来以为原理的东西都非常高深,没想到vue的双向绑定真的很好理解啊...自己动手写了一个. 传送门 双向绑定的思想 双向数据绑定的思想就是数据层与 ...

  6. Android Studio-—使用OpenCV的配置方法和demo以及开发过程中遇到的问题解决

    前提: 1.安装Android Studio(过程略) 2.官网下载OpenCV for Android 网址:http:opencv.org/downloads.html 我下载的是下图的版本 3. ...

  7. iOS之ProtocolBuffer搭建和示例demo

    这次搭建iOS的ProtocolBuffer编译器和把*.proto源文件编译成*.pbobjc.h 和 *.pbobjc.m文件时,碰到不少问题! 搭建pb编译器到时没有什么问题,只是在把*.pro ...

  8. 钉钉开放平台demo调试异常问题解决:hostname in certificate didn't match

    今天研究钉钉的开放平台,结果一个demo整了半天,这帮助系统写的也很难懂.遇到两个问题: 1.首先是执行demo时报unable to find valid certification path to ...

  9. 无限分级和tree结构数据增删改【提供Demo下载】

    无限分级 很多时候我们不确定等级关系的层级,这个时候就需要用到无限分级了. 说到无限分级,又要扯到递归调用了.(据说频繁递归是很耗性能的),在此我们需要先设计好表机构,用来存储无限分级的数据.当然,以 ...

随机推荐

  1. Struts2(result 流 )下载

    jsp: <body> <a href="stream.action?fileName=psb.jpg">psb</a> <br> ...

  2. model中字段格式验证

    注释部分在前端不显示 /// <summary> /// 链接地址 /// </summary> [Display(Name = "链接地址")] //[D ...

  3. Shell脚本,自动化发布tomcat项目【转载】

    Shell脚本,自动化发布tomcat项目脚本. 1. vko2c_auto_build_by_scp.sh 文件内容: #---------------------start------------ ...

  4. PHP数学函数试题

    1.求绝对值的函数是什么? 2.在任意进制之间转换数字的函数是什么? 3.二进制转换为十进制,十进制转换为二进制,十六进制转换为十进制,十进制转换为十六进制,八进制转换为十进制,十进制转换为八进制的函 ...

  5. python引入模块时import与from ... import的区别

    import datetime是引入整个datetime包,如果使用datetime包中的datetime类,需要加上模块名的限定. import datetime print datetime.da ...

  6. sql语句按月份统计查询

    select year(createdate) 年,month(createdate) 月,count(1) from public_cms_arcwhere (userid in (select i ...

  7. mysql 修改 添加 删除 表字段

    添加表的字段    alter table 表名  add  字段名  字段的类型 例子:        alter table table1 add transactor varchar(10) n ...

  8. 留言本,keyCode

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  9. Django - 通用视图

    urls.py from . import views ... url(r'^$', views.IndexView.as_view, name="index"), url(r'^ ...

  10. LISTVIEW嵌套GRIDVIEW的一些处理(点击GRIDVIEW的条目,能够显示他在LISTVIEW中的位置)(对这篇文章的优化处理,不每次都new onItemClickListener)

    前几天写了点击GRIDVIEW的条目,能够显示他在LISTVIEW中的位置,当时的处理是在ListView的适配器里的GetView方法里每次都new GridView的onItemClickList ...