日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

Spring.NET学习笔记(4)-对象作用域和类型转换

發布時間:2025/3/19 asp.net 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring.NET学习笔记(4)-对象作用域和类型转换 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


一.作用域

作為對象定有生命周期,singleton和prototype是最基本的實例狀態,其他三個則是對于web平臺而言的。熟悉asp.net的則一看便清楚了.


作用域描述

singleton

在每個Spring IoC容器中一個bean定義對應一個對象實例。

prototype

一個bean定義對應多個對象實例。

request

在一次HTTP請求中,一個bean定義對應一個實例;即每次HTTP請求將會有各自的bean實例, 它們依據某個bean定義創建而成。該作用域僅在基于web的Spring ApplicationContext情形下有效。

session

在一個HTTP Session中,一個bean定義對應一個實例。該作用域僅在基于web的Spring ApplicationContext情形下有效。

application

在一個全局的HTTP Session中,一個bean定義對應一個實例。典型情況下,僅在使用portlet context的時候有效。該作用域僅在基于web的Spring ApplicationContext情形下有效。


以下兩幅圖很好的表達了singleton和prototype的概念


二.類型轉換器


類型轉換器是.net已經有的概念,其實類型轉換器的概念在.net中用的很廣,asp.net,wpf則到處是類型轉換器,只不過平時大家很少用,因為基本的類型.net都幫你做了內置轉換。以下是內置spring支持的類型轉換器,當然也可以自己擴展,擴展的配置文件需要通過配置來擴展。

TypeExplanation
RuntimeTypeConverterParses strings representing System.Types to actual System.Types and the other way around.
FileInfoConverterCapable of resolving strings to a System.IO.FileInfo object.
StringArrayConverterCapable of resolving a comma-delimited list of strings to a string-array and vice versa.
UriConverterCapable of resolving a string representation of a Uri to an actual Uri-object.
CredentialConverterCapable of resolving a string representation of a credential for Web client authentication into an instance of System.Net.ICredentials
StreamConverterCapable of resolving Spring IResource Uri (string) to its corresponding InputStream-object.
ResourceConverterCapable of resolving Spring IResource Uri (string) to an IResource object.
ResourceManagerConverterCapable of resolving a two part string (resource name, assembly name) to a System.Resources.ResourceManager object.
RgbColorConverterCapable of resolving a comma separated list of Red, Green, Blue integer values to a System.Drawing.Color structure.
ExpressionConverterCapable of resolving a string into an instance of an object that implements the IExpression interface.
NameValueConverterCapable of resolving an XML formatted string to a Specialized.NameValueCollection
RegexConverterCapable of resolving a string into an instance of Regex
RegistryKeyConverterCapable of resolving a string into a Microsoft.Win32.RegistryKey object.


這部分先了解,用到再看

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的Spring.NET学习笔记(4)-对象作用域和类型转换的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。