嵌入查看文件里面为二进制资源 [英] Embedding View files as resource inside Binary

查看:141
本文介绍了嵌入查看文件里面为二进制资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个.NET库很少控制器,我要重用他们在多个Web项目。

I am trying to create a .Net Library with few Controllers, and i want to reuse them in Multiple web projects.

我通过我的一半,但问题我得到是,每当我的库添加到新的Web项目,我需要分别复制所有相应的视图文件到新的项目。每当我更新了图书馆,我需要再次重复这些步骤。

I'm half way through, But problem i'm getting is , Whenever i add the library to the new web project , i need to copy all corresponding view files separately to the new project. Whenever i update the library, i need to repeat the steps again.

有什么办法,我可以嵌入查看文件里面的DLL作为资源,并把它传递查看()函数作为一个嵌入式的资源。

Is there any way , i can embed View files inside dll as resource , and pass it to "View()" function as an embedded resource.

我想要实现的是,我希望把控制器和内部单个DLL文件对应的观点,这样我可以轻松地分发/管理库作为一个单独的dll文件

(鸿辉我已经找到,正在创造与IVIEW界面自定义视图类,并直接写入HTML输出作家渲染输出,但我preFER使用视图文件。)

( Oneway i already found , is creating custom view class with IView Interface and Render the output directly by writing to HTML Output Writer, But i prefer to use the View file.)

推荐答案

菲尔哈克刚刚发布了的博客帖子前几天这可能会帮助你;他用一个数据库来存储的意见和红宝石来处理他们,但我想你可以把他的原型,并使其存储在一个单独的程序很容易意见工作。

Phil Haack just posted a blog post a few days ago that would probably help you; He's using a database to store the views and ruby to process them, but I would think you could take his prototype and make it work for views stored in a separate assembly fairly easily.

公正,快速浏览通过code我觉得魔术酱将被实施VirtualPathProviderViewEngine(例如,见RubyViewEngine级),并插入您的视图引擎为ViewEngines.Engines集(见Global.asax中。 CS)。

Just a quick glance through the code and I think the magic sauce is going to be implementing VirtualPathProviderViewEngine (See the "RubyViewEngine" class for example) and inserting your ViewEngine into ViewEngines.Engines Collection (see Global.asax.cs).

这篇关于嵌入查看文件里面为二进制资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆