首页 > 开发 > 综合 > 正文

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收集整理,欢迎访问。
  • 发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表