惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Archives - TechRepublic
Security Archives - TechRepublic
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
T
Threatpost
P
Proofpoint News Feed
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
G
GRAHAM CLULEY
Cisco Talos Blog
Cisco Talos Blog
Simon Willison's Weblog
Simon Willison's Weblog
L
Lohrmann on Cybersecurity
Scott Helme
Scott Helme
T
Tenable Blog
L
LINUX DO - 最新话题
Help Net Security
Help Net Security
WordPress大学
WordPress大学
Hacker News: Ask HN
Hacker News: Ask HN
人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Announcements
Recent Announcements
Vercel News
Vercel News
The Hacker News
The Hacker News
J
Java Code Geeks
博客园 - 【当耐特】
D
Docker
V
V2EX
H
Heimdal Security Blog
GbyAI
GbyAI
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News | PayPal Newsroom
The Register - Security
The Register - Security
The Cloudflare Blog
C
CERT Recently Published Vulnerability Notes
T
The Blog of Author Tim Ferriss
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
SecWiki News
SecWiki News
S
Secure Thoughts
Attack and Defense Labs
Attack and Defense Labs
Microsoft Security Blog
Microsoft Security Blog
S
Schneier on Security
Latest news
Latest news
Project Zero
Project Zero

博客园 - Awen

asp.net插件实现 一些顶级的设计站点(陆续更新) asp.net定时任务实现(原创) Monorail的一些常用的东西(验证码,分页。。。持续更新) SubSonic:我想要的动态查询 SubSonic:亚音速之光 一个顶N个的NextResult 自娱自乐 3.5 -开篇有益 WinFormUI-Docking初级使用 一个喜欢网页设计的程序员 一个关于Excel的处理类(部分参考网络上) 抛开映射关系,不oo的数据访问写法 Javascript改观过程2 Javascript改观过程1 - Awen - 博客园 CEIMS项目笔记2:重复的,让工具做去! 备份&收集(持续更新)! CEIMS开发日记:项目计划 Jsp,.net! asp.net优化探讨系列(3)
基于Monorail的系统功能模块化
Awen · 2008-05-18 · via 博客园 - Awen

     模块化总是让人比较容易理解的,如果你的程序可以让人很容易理解,那是多么美好的事情!不论是对自己或是对别人。N层的开发让人看到了模块化的威力,这里不讨论整个系统的结构,而是细分到系统的每个功能,比如说一个网站的功能,可能有会员管理模块,有内容管理模块等等,DNN等一系列cms在这点的实现是很强大的,但是似乎真的“大”了一点。最近看了一些基于插件式的内容管理系统,不免让人觉得有些过度设计的感觉,web本该如此简单,太复杂的架构感觉有点沉重。最近用到Castle的Monorail,发现了一个好玩的东西,说出来分享下,知道的就不要乱拍啦!
首先我有一个简单的网站,里面已经有几个简单的功能了。因为简单,所以就想不断地完善,添加功能,步骤很简单。
看配置文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    
<configSections>
        
<section name="monorail" type="Castle.MonoRail.Framework.Configuration.MonoRailSectionHandler, Castle.MonoRail.Framework" />
    
</configSections>
    
<!-- 
        For more on MonoRail configuration see 
        http://www.castleproject.org/monorail/documentation/v1rc3/index.html
    
-->
    
<monorail smtpHost="yoursmtphost" useWindsorIntegration="false">
        
<controllers>
            
<assembly>ExPortal</assembly>
      
<assembly>ControlOther</assembly>
        
</controllers>
        
<viewEngines viewPathRoot="Views">
            
<add xhtml="false" type="Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine, Castle.MonoRail.Framework.Views.NVelocity" />
        
</viewEngines>
    
</monorail>
    
<system.web>
        
<httpHandlers>
            
<add verb="*" path="*.castle" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework" />
            
<!-- block direct user access to template files -->
            
<add verb="*" path="*.vm" type="System.Web.HttpForbiddenHandler" />
            
<add verb="*" path="*.njs" type="System.Web.HttpForbiddenHandler" />
            
<add verb="*" path="*.brail" type="System.Web.HttpForbiddenHandler" />
            
<add verb="*" path="*.brailjs" type="System.Web.HttpForbiddenHandler" />
            
<add verb="*" path="*.st" type="System.Web.HttpForbiddenHandler" />
        
</httpHandlers>
        
<httpModules>
            
<add name="monorail" type="Castle.MonoRail.Framework.EngineContextModule, Castle.MonoRail.Framework" />
        
</httpModules>
    
</system.web>
</configuration>

看看Controllers下的子节点,我配置了两个Assembly,ControlOther里面有我新加的功能模块GameController类,下面只是个例子,

using System;
using System.Collections.Generic;
using System.Text;
using Castle.MonoRail.Framework;
namespace ControlOther
{
    
public class GameController:Controller
    {
        
public void index()
        {
            PropertyBag[
"name"= "Awen";
        }
    }
}

编译,将dll拷贝到web applaction 的bin文件夹里,然后在Web里面views文件夹里面添加vm(view,视图文件)
ok,现在就可以访问game/index.rail了,不信,你试试看吧!
当然,这里添加模块是基于web.config的,我看了源代码,用如下代码可以设置Assemblies。
 

ControllersConfig con = MonoRailConfiguration.GetConfig().ControllersConfig;
con.Assemblies = new string[] { "ExPortal", "ControlOther" };


或许可以重写Monorail读取配置的代码,改为以数据库为存储,加以缓存依赖,下次再研究下。不知这样算不算一个可插拔的系统呢?但是好像在运行期改变Controller的Assemblies后也没效果哦,暂时没找到,如果有同学知道,说声咯!