Websharp使用說明(6)
2024-07-21 02:17:16
供稿:網友
 
websharp應用系統的配置
1、 緩存的配置
websharp使用了微軟的cached application block來緩存數據,因此,下面的緩存信息必須在應用程序中添加。關于cached application block,可以參見微軟的相關文檔。
<configuration>
 <configsections>
 <section name="cachemanagersettings" type="microsoft.applicationblocks.cache.cacheconfigurationhandler,microsoft.applicationblocks.cache" />
 <section name="websharpexpirationpolicy" type="websharp.service.websharpcofigurationhandler,websharp" />
 </configsections>
 <cachemanagersettings>
 <!-- data protection settings
 use dataprotectioninfo to set the assembly and class which implement
 the dataprotection interfaces for the cache.
 -->
 <dataprotectioninfo assemblyname="microsoft.applicationblocks.cache" 
 classname="microsoft.applicationblocks.cache.dataprotection.defaultdataprotection" 
 validationkey="oci44oq9c3xadq3/bmhpkspfzetezlkxen/ahq8t7nvk/kmgafnssqjr00kunhrso+mplvwaingep6i14x9m+a=="
 validation="sha1"/> 
 
 <!-- storage settings
 use storageinfo to set the assembly and class which implement
 the storage interfaces for the cache.
 
 modes: inproc, outproc
 -->
 <storageinfo assemblyname="microsoft.applicationblocks.cache" classname="microsoft.applicationblocks.cache.storages.singletoncachestorage" mode="inproc" validated="true" encrypted="true" remotingurl="tcp://localhost:8282/cacheservice" />
 <!--storageinfo assemblyname="microsoft.applicationblocks.cache" classname="microsoft.applicationblocks.cache.storages.sqlservercachestorage" mode="inproc" connectionstring="user id=sa;password=msljkdv1;network=dbmssocn;database=cacheab;server=msljksrv02" encrypted="true" validated="true" applicationname="sports" remotingurl="tcp://localhost:8282/cacheservice" /-->
 <!--<storageinfo assemblyname="microsoft.applicationblocks.cache" classname="microsoft.applicationblocks.cache.storages.mmfcachestorage" mode="inproc" basepath="c:/mmfcache/" encrypted="true" validated="true" mmfdictionarysize="1048576" remotingurl="tcp://localhost:8282/cacheservice"/>-->
 
 <!-- 
 mmfdictionarysize - it is the size (in bytes) of the dictionary object (in mmfcachestorage) used to store the references of cache items. 
 -->
 
 <!-- scavenging settings
 use the scavengingalgorithm to set a class that will be executed when
 scavenging is performed.
 -->
 
 <scavenginginfo assemblyname="microsoft.applicationblocks.cache" classname="microsoft.applicationblocks.cache.scavenging.lruscavenging" memorypollingperiod="60" utilizationforscavenging="80" maximumsize="5"/>
 <!-- expiration settings
 use the expirationcheckinterval to change the interval to check for 
 cache items expiration. the value attribute is represented in seconds.
 -->
 <expirationinfo interval="1" />
 </cachemanagersettings> 
 <websharpexpirationpolicy>
 <expirationpolicy expirationcheckinterval="60" assemblyname="microsoft.applicationblocks.cache" classname="microsoft.applicationblocks.cache.expirationsimplementations.slidingtime" />
 </websharpexpirationpolicy>
</configuration>
 
 
2、 系統持久化配置信息
配置persistenceproperty,對于web應用系統,可以在global.asax中配置,對于windows應用程序,可以在程序初始化時設置。
下面是設置的一個例子:
persistenceproperty pp=new persistenceproperty();
pp.connectionstring="server=127.0.0.1;uid=sa;pwd=;database=logisticsdemo;";//數據庫連接字符串
pp.databasetype=databasetype.mssqlserver; //數據庫類型
[email protected]"websharptestlib,websharptestlib.xml"; //xml定義文件的路徑
pp.mapfilelocationtye=mapfilelocationtype.assembly; //xml文件路徑的類型
pp.userid="sa"; //數據庫用戶名,必須與數據庫連接字符串中的用戶名一致
pp.password=""; //數據庫用戶密碼,必須與數據庫連接字符串中的用戶密碼一致
applicationconfiguration.defaultpersistenceproperty=pp; //設置應用程序的默認配置屬性
 
配置信息的說明如下:
1) 數據庫連接字符串、用戶名和密碼的設置按照常規設置
2) mapfilelocationtye指明xml映射文件的路徑類型,可以有三種類型:
a) absolutepath:采用絕對路徑的形式,在這種情況下,mapfilelocation設置成絕對路徑的形式,如:“d:/apppath/xml”。
b) virtualpath:對于web應用程序,可以設置為虛擬路徑的形式,如“/mywebapp/entitydefinitions/”。
c) assembly:xml文件作為資源文件被編譯。采用這種形式,需要將xml文件的生成操作屬性設置成“嵌入的資源”,這種情況下,mapfilelocation的格式為:“assemblyname,namespace”。例如,xml文件位于websharptestlib項目的xml文件夾下面,mapfilelocation可以設置為:“websharptestlib,websharptestlib.xml”
本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。