码迷,mamicode.com
首页 > 编程语言 > 详细

2018.4.16Spring.Net入门学习内容

时间:2018-04-16 16:18:55      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:就是   system   struct   val   实现   utf-8   cts   自己   text   

三大方面:

IoC:Inversion of Control

控制翻转:就是创建对象的权利由开发人员自己控制New,转到了由容器来控制。

DI:Dependency Injection
It is a process whereby objects define their dependencies, that is, the other objects they work with, only through constructor arguments and properties that are set on the object instance after it is constructed. 
依赖注入:就是在通过容器来创建对象的时候,在对象的初始化是可以给一些属性、构造方法的参数等注入默认值(可以是复杂的类型.

Aop--权限校验--日志处理。Filter.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

开始配置VS:

技术分享图片

1:引用System.Core 和 Common.Logging 两个服务引用

 

技术分享图片

选4.0和发布版的

 

技术分享图片

添加APP.config配置文件,代码如下:

 1 <?xml version="1.0" encoding="utf-8" ?>
 2 <configuration>
 3     <configSections>
 4         <sectionGroup name="spring">
 5             <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
 6             <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
 7         </sectionGroup>
 8     </configSections>
 9     <spring>
10         <context>
11             <resource uri="config://spring/objects"/>
12         </context>
13         <objects xmlns="http://www.springframework.net">
14             <object name="UserInfo"
15                     type="SpringNet.Userinfo,SpringNet">
16                 <property name="name"  value="刘军"/>
17                 <property name="book"  ref="BookInfo"/>
18             </object>
19             <object name="BookInfo"
20                 type="SpringNet.book,SpringNet">
21                 <property name="bookName"  value="三国演义"/>
22                 <property name="bookSal"  value="89"/>
23             </object>
24 
25 
26 
27         </objects>
28     </spring>
29 </configuration>
   <object name="UserInfo"
15                     type="SpringNet.Userinfo,SpringNet">
16                 <property name="name"  value="刘军"/>
17                 <property name="book"  ref="BookInfo"/>
18             </object>
   一个</object>代表一个类的声明,name代表名称,要和前面代码名称一样,type代表当前命名空间下的类,命名空间。
技术分享图片
定义一个接口定义方法。

技术分享图片

声明一个类实现该接口。返回的是配置文件中Value的值;

 

技术分享图片


定义程序的主入口Main方法

运行效果如下:

技术分享图片

 

当点击BUtton按钮时,返回输出格式字符串:值是配置文件中默认的值。

2018.4.16Spring.Net入门学习内容

标签:就是   system   struct   val   实现   utf-8   cts   自己   text   

原文地址:https://www.cnblogs.com/FalseNull/p/8856002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!