asp.net开发WAP网站及集成在线wap模拟器(5)
ParamRules实现如下: Code [http://www.xueit.com] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace Rsion.Web{ /// summary ///
ParamRules实现如下:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace Rsion.Web { /// <summary> /// 模板参数规则类 /// </summary> public class ParamRules:IEnumerable { private Dictionary<string, object> rules; public ParamRules() { if (rules == null) rules = new Dictionary<string, object>(); } public object this[string paramKey] { get { if (rules.ContainsKey(paramKey)) return rules[paramKey]; return ""; } set { if (rules.ContainsKey(paramKey)) rules[paramKey] = value; else rules.Add(paramKey, value); } } /// <summary> /// 添加新的规则 /// </summary> /// <param name="paramKey"></param> /// <param name="paramValue"></param> public void Add(string paramKey, object paramValue) { if (rules.ContainsKey(paramKey)) throw new ArgumentException("对不起规则已经存在!Key:" paramKey ",Value:" rules[paramKey].ToString(), "paramKey"); rules.Add(paramKey, paramValue); } public void Remove(string paramKey, object paramValue) { if (rules.ContainsKey(paramKey)) rules.Remove(paramKey); } #region IEnumerable 成员 public IEnumerator GetEnumerator() { foreach (KeyValuePair<string, object> k in rules) { yield return k; } } #endregion } }
Template.cs实现如下:

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Rsion.Web { /// <summary> /// 模板 /// </summary> public class Template { public static Template _template; private static ParamRules rules; private Template() { } public static Template CreateInstance() { if (_template == null) _template = new Template(); return _template; } public ParamRules Rules { get { if (rules == null) rules = new ParamRules(); return rules; } } } }
这样我们先在global.asax中填加一些模板数据,这样才可以解析模板,解析模板的功能实现在PageAdapter中,这样可以
在本页面直接调用Html.RenderPartial("template")调用
精彩图集
精彩文章
热门标签
mysql自动备份
dll生成lib
connections
nginx
相册
3D扇形
捕获
双括号
SQLAlchemy
虚继承
验证用户名
os模块
bg
is
创建Web服务
屏蔽HOME键
data-*
Twitter
页面显示
华为
dbi
overload
城市判断
过滤选择器
Oracle用户解锁
边
连续获取
基础 无域
updatepanel用
js获取属性
readfile
解
构造icmp
逐行读取
水平滚动
读写分离
getopt模块
PHPThumb
自动调节
移除tr
音效
简介
排序数组
WinExec
大容量数据
sql数据库连接
脚本全局
charset
不用图片
mbstring扩展
php变量作用域
logcat命令
线程并发
横向报表
JS获取URL
目标函数
主框架
主分区
并发插入优化
PHP ddos
赞助商链接
@CopyRight 2002-2008, 1SOHU.COM, Inc. All Rights Reserved QQ:1010969229