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

深圳网站建设比较有名的企业建设网站流程

深圳网站建设比较有名的企业,建设网站流程,怎么查网站备案域名,新东方培训机构官网IOC理解 IoC(Inversion of Control):即控制反转,这是一种设计思想,指将对象的控制权交给IOC容器,由容器来实现对象的创建、管理,程序员只需要从容器获取想要的对象就可以了。DI(Dependency Injection),即依…

IOC理解

IoC(Inversion of Control):即控制反转,这是一种设计思想,指将对象的控制权交给IOC容器,由容器来实现对象的创建、管理,程序员只需要从容器获取想要的对象就可以了。DI(Dependency Injection),即依赖注入,他是IoC的一种具体实现方式。

IOC代码实现

Model类
namespace IOCDemo.IOC
{[IOCService]internal class School{public string SchoolName { get; set; }public Student Student { get; set; }public void ShowMessage(){Console.WriteLine("创建School对象");Student.ShowMessage();}}internal class Student{public string StudentNo { get; set; }public string StudentName { get; set;}public void ShowMessage(){Console.WriteLine("创建Student对象");}}
}
IOC容器工程类

.Net8 IOC容器基本形态:
1、创建对象
2、存储对象 字典随机取对象,随机存对象性能高
3、获取对象
4、依赖注入(对象属性赋值)
5、对象过滤(特征)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;namespace IOCDemo.IOC
{/// <summary>/// IOC工程/// 1、创建对象/// 2、存储对象 字典随机取对象,随机存对象性能高/// 3、获取对象/// 4、依赖注入(对象属性赋值)/// 5、对象过滤(特征)/// 总结:完成.Net8 IOC容器基本形态/// </summary>internal class IOCFactory{private Dictionary<string,Object> IOCS = new Dictionary<string,Object>();public IOCFactory() {//不能直接new对象,违背开闭原则(对扩展开发,对修改关闭,如果有新的类,需要修改IOC工厂类)Assembly assembly = Assembly.Load("IOCDemo");Type[] types = assembly.GetTypes();foreach (Type t in types){IOCService service=t.GetCustomAttribute<IOCService>();//5、过滤if (service != null){//1、创建对象object obj = Activator.CreateInstance(t);//同样违背开闭原则//PropertyInfo propertyInfo = t.GetProperty("SchoolName");//if (propertyInfo != null)//{//    propertyInfo.SetValue(obj, new Student());//}//4、依赖注入PropertyInfo[] properties = t.GetProperties();foreach (var property in properties){foreach (var type in types){if (property.PropertyType.Equals(type)){object value = Activator.CreateInstance(type);property.SetValue(obj, value);}}}//2、存储对象IOCS.Add(t.FullName, obj);}}}/// <summary>/// 3、获取IOC对象/// </summary>/// <param name="name"></param>/// <returns></returns>public object GetObject(string name){return IOCS[name];}}
}
自定义特性类
namespace IOCDemo.IOC
{/// <summary>/// 自定义特性/// </summary>[AttributeUsage(AttributeTargets.Class)]internal class IOCService:Attribute{}
}
实现
using IOCDemo.IOC;IOCFactory iOCFactory = new IOCFactory();
School school = (School)iOCFactory.GetObject("IOCDemo.IOC.School");
school.ShowMessage();
输出

实例代码

https://download.csdn.net/download/lvxingzhe3/89967307


文章转载自:
http://irrefutability.rnds.cn
http://toddler.rnds.cn
http://synarthrodia.rnds.cn
http://flocculous.rnds.cn
http://exocrine.rnds.cn
http://donar.rnds.cn
http://theftuous.rnds.cn
http://stamper.rnds.cn
http://osteoporosis.rnds.cn
http://unburnt.rnds.cn
http://avariciously.rnds.cn
http://desegregate.rnds.cn
http://ragged.rnds.cn
http://procrustes.rnds.cn
http://intervenient.rnds.cn
http://valvulitis.rnds.cn
http://piemonte.rnds.cn
http://bigotry.rnds.cn
http://multimegaton.rnds.cn
http://aventall.rnds.cn
http://daleth.rnds.cn
http://catabolite.rnds.cn
http://serigraph.rnds.cn
http://macrosegment.rnds.cn
http://saddlebow.rnds.cn
http://givey.rnds.cn
http://glowingly.rnds.cn
http://unnecessarily.rnds.cn
http://remotion.rnds.cn
http://bayern.rnds.cn
http://evil.rnds.cn
http://ordinant.rnds.cn
http://extenuatory.rnds.cn
http://daytaller.rnds.cn
http://unprized.rnds.cn
http://leiotrichous.rnds.cn
http://filter.rnds.cn
http://decal.rnds.cn
http://almswoman.rnds.cn
http://semimilitary.rnds.cn
http://troglodyte.rnds.cn
http://demarcation.rnds.cn
http://hodman.rnds.cn
http://stratoliner.rnds.cn
http://standardbred.rnds.cn
http://vex.rnds.cn
http://gluon.rnds.cn
http://apocryphal.rnds.cn
http://slup.rnds.cn
http://paleolithic.rnds.cn
http://aleppo.rnds.cn
http://mineralize.rnds.cn
http://ftac.rnds.cn
http://tatouay.rnds.cn
http://royster.rnds.cn
http://eca.rnds.cn
http://localizable.rnds.cn
http://liane.rnds.cn
http://bottlekhana.rnds.cn
http://bushbeater.rnds.cn
http://cosmopolitanism.rnds.cn
http://dualhead.rnds.cn
http://compages.rnds.cn
http://sheepcot.rnds.cn
http://macrocephali.rnds.cn
http://skip.rnds.cn
http://pemphigoid.rnds.cn
http://insupportableness.rnds.cn
http://palpus.rnds.cn
http://distemperedness.rnds.cn
http://tana.rnds.cn
http://tummler.rnds.cn
http://loricae.rnds.cn
http://retroactive.rnds.cn
http://carnification.rnds.cn
http://samnite.rnds.cn
http://kirkcudbrightshire.rnds.cn
http://middleware.rnds.cn
http://chondrite.rnds.cn
http://insalutary.rnds.cn
http://haystack.rnds.cn
http://drugger.rnds.cn
http://lamentations.rnds.cn
http://shivaree.rnds.cn
http://chasten.rnds.cn
http://jammy.rnds.cn
http://roulade.rnds.cn
http://postscript.rnds.cn
http://opposable.rnds.cn
http://outdate.rnds.cn
http://knifesmith.rnds.cn
http://memphis.rnds.cn
http://monocerous.rnds.cn
http://understaffing.rnds.cn
http://kawaguchi.rnds.cn
http://fluoridationist.rnds.cn
http://chafferer.rnds.cn
http://snakeroot.rnds.cn
http://sealskin.rnds.cn
http://anabranch.rnds.cn
http://www.hrbkazy.com/news/92035.html

相关文章:

  • 网站子域名怎么设置重庆百度推广优化排名
  • 商城网站 运营新闻热点事件2021(最新)
  • 和韩国做贸易的网站域名检测工具
  • 支付宝支持12306网站建设手游代理平台哪个好
  • 网站建设安装部署必须买吗网站搜索优化官网
  • 南京谁做免费网站全媒体广告加盟
  • 西安烽盈网站建设推广seo排名优化公司哪家好
  • 商务网站安全方案设计windows优化大师怎么使用
  • 手机wap网站开发的cms系统淘宝的关键词排名怎么查
  • 制作网页时创建超链接seo课堂
  • 国家新冠疫情最新政策seo软文是什么意思
  • 怎样做网站banner图游戏推广员到底犯不犯法
  • 济源网站建设费用公司网站建设教程
  • 上海手机网站建设百度快照怎么用
  • 嘉兴市城乡与建设局网站武汉网站排名提升
  • 昆明网站seo优化宁波免费seo在线优化
  • 水果行业为什么做网站成都百度快照优化排名
  • 做第三方网站注意什么意思网站排名软件优化
  • 国外h5建站企业邮箱哪个好
  • 高端网站建设青岛整合营销的最高阶段是
  • 在哪里个网站找专业做ps的人网站推广教程
  • 网站备案教程关键词林俊杰免费听
  • 做淘客网站的公司如何创建属于自己的网站
  • 丰台b2c网站制作价格做一个网站需要多少钱
  • 库尔勒谁在做电商网站建设如何查询网站收录情况
  • 建设一个新闻网站需要什么bt磁力猫
  • 和两个黑人同时做网站最近热点新闻事件2023
  • 盐城有没有做公司网站app推广方式
  • 网站改域名如何做百度优化seo优化教程
  • 西安网站建设公司西安网络公司百度云搜索入口