上一篇:Websharp使用说明(7) >>
Websharp使用说明(6)
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; //数据库类型
pp.MapFileLocation=@"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”
下一篇:Websharp使用说明(5) >>
相关文章:
- · 开发合作 Microsoft .NET 解决方案
- · Microsoft .NET 框架常见问题
- · Effective C#-Working with Strings
- · 使用WMI获得硬盘的信息
- · MSBuild入门
- · ADO.NET对象的构造(7)_OleDbParameter(中)
- · ADO.NET对象的构造(7)_OleDbParameter(上)
- · ADO.NET对象的构造(4)_DataColumn(续)
- · ADO.NET对象的构造(3)_DataTable(续)
- · .NET开发平台研究(四)
- · .Net开发平台研究(三)
- · .Net开发平台研究(二)
- · .Net开发平台研究(一
- · .NET 对 J2EE[2]
- · Microsoft .NET与J2EE的比较[E]
- · .NET P2P: Writing Peer-to-Peer Networked Apps with the Microsoft .NET Framework
- · Vb.Net问题集
- · Microsoft .NET 框架和 Visual Studio.NET 中的 SOAP
- · Windows XP 和 .NET:期望什么?
- · .NET的目标(续)
- · .NET的目标
- · 微软放出.net牌 中国软件再次面临“站队”
- · .NET真面目(下)
- · .NET真面目(上)
- · .Net:解读微软互联网新战略(下)
- · Net:解读微软互联网新战略(上)
- · .NET的精华二(开拓者必看)
- · .NET的精华一(开拓者必看)
- · 小道消息-微软的 .NET将会支持Linux
- · 微软 .NET laza
- · .NET中的特殊类型成员
- · 微软.NET平台中类型使用的基本原理
- · Microsoft .NET 框架和 Visual Studio.NET 中的 SOAP
- · 利用 .NET 框架简化发布和解决 DLL Hell 问题
- · 由一个性能问题引出的.net概念
- · VS.NET下水晶报表分发时的问题及解决2
- · .NET框架与COM
- · XML、Web服务和.NET框架
