标签:
Abcbokesdfklsdjlf※
11111111111111111111111111111111111111111111111111111111111111111111111 |
?
1111111 | Uuiu | Iii |
Iooo | Pppp | ppppoj |
? | ? | ? |
? | ? | ? |
? | ? | ? |
? | ? | ? |
? | ? | ? |
?
var htmlstr = "<object classid=‘clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95‘ id=‘MediaPlayer1‘ width=‘" + getFullHeight().width + "‘ height=‘450‘>"; htmlstr += "<param name=‘allowFullScreen‘ value=‘true‘/>" htmlstr += "<param name=‘Filename‘ value=‘‘/>" htmlstr += "</object>"; $("#player").html(htmlstr); |
?
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,Microsoft.Practices.Unity.Configuration"/> </configSections> <unity> <!--定义类型别名--> <aliases> <add alias="IProduct" type="UnityDemo.IProduct,UnityDemo" /> <add alias="Milk" type="UnityDemo.Milk,UnityDemo" /> <add alias="Sugar" type="UnityDemo.Sugar,UnityDemo" /> ? <add alias="IPerson" type="IClass.IPerson,IClass" /> <add alias="Chinese" type="DIDemo.Chinese,DIDemo" /> </aliases> ? <!--容器--> <container name="mycontainer"> <!--映射关系--> <register type="IProduct" mapTo="Milk"></register> <register type="IProduct" mapTo="Sugar" name="Sugar"></register> <register type="IPerson" mapTo="Chinese" name="c"></register> </container> </unity> </configuration> |
?
static void Main(string[] args) { //ContainerCode(); ? ContainerConfiguration(); ? ? Console.ReadKey(); } ? ? static void ContainerCode() { IUnityContainer container = new UnityContainer(); ? //默认注册(无命名),如果后面还有默认注册会覆盖前面的 container.RegisterType<IProduct, Milk>(); ? //ContainerControlledLifetimeManager,注册为单例类 //container.RegisterType<IProduct, Milk>(new ContainerControlledLifetimeManager()); ? //命名注册 container.RegisterType<IProduct, Sugar>("Sugar"); ? //解析默认对象 IProduct _product = container.Resolve<IProduct>(); _product.ClassName = _product.GetType().ToString(); _product.ShowInfo(); ? //指定命名解析对象 IProduct _sugar = container.Resolve<IProduct>("Sugar"); _sugar.ClassName = _sugar.GetType().ToString(); _sugar.ShowInfo(); ? IEnumerable<IProduct> classList = container.ResolveAll<IProduct>(); ? foreach (var item in classList) { item.ClassName = item.GetType().ToString(); item.ShowInfo(); } } ? ? //配置文件注入代码 static void ContainerConfiguration() { IUnityContainer container = new UnityContainer(); ? UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity"); section.Configure(container, "mycontainer");//mycontainer ? IProduct product = container.Resolve<IProduct>("Sugar"); product.ClassName = "fjsdkjflksd"; product.ShowInfo(); ? IPerson p = container.Resolve<IPerson>("c"); string a = p.Speak(); Console.WriteLine(a); } |
Test,使用word发布博客12332434345454654
标签:
原文地址:http://www.cnblogs.com/liuguangyin/p/4964920.html