nopcommerce 4.1 core 插件 相关1
nop中 插件机制是比较值得学习的:
Nop 插件学习:
1、 项目里面的生成必须是采用 直接编辑项目文件,参考nop原本的项目文件

动态加载插件的方法-mvc3 参考:
using System.Linq;
using System.Web;
using System.IO;
using System.Web.Hosting;
using System.Web.Compilation;
using System.Reflection;
[assembly: PreApplicationStartMethod(typeof(PluginFramework.Plugins.PreApplicationInit), "Initialize")]
namespace PluginFramework.Plugins
{
public class PreApplicationInit
{
static PreApplicationInit()
{
PluginFolder = new DirectoryInfo(HostingEnvironment.MapPath("~/plugins"));
ShadowCopyFolder = new DirectoryInfo(HostingEnvironment.MapPath("~/plugins/temp"));
}
/// <summary>
/// The source plugin folder from which to shadow copy from
/// </summary>
/// <remarks>
/// This folder can contain sub folderst to organize plugin types
/// </remarks>
private static readonly DirectoryInfo PluginFolder;
/// <summary>
/// The folder to shadow copy the plugin DLLs to use for running the app
/// </summary>
private static readonly DirectoryInfo ShadowCopyFolder;
public static void Initialize()
{
Directory.CreateDirectory(ShadowCopyFolder.FullName);
//clear out plugins)
foreach (var f in ShadowCopyFolder.GetFiles("*.dll", SearchOption.AllDirectories))
{
f.Delete();
}
//shadow copy files
foreach (var plug in PluginFolder.GetFiles("*.dll", SearchOption.AllDirectories))
{
var di = Directory.CreateDirectory(Path.Combine(ShadowCopyFolder.FullName, plug.Directory.Name));
// NOTE: You cannot rename the plugin DLL to a different name, it will fail because the assembly name is part if it's manifest
// (a reference to how assemblies are loaded: http://msdn.microsoft.com/en-us/library/yx7xezcf )
File.Copy(plug.FullName, Path.Combine(di.FullName, plug.Name), true);
}
// Now, we need to tell the BuildManager that our plugin DLLs exists and to reference them.
// There are different Assembly Load Contexts that we need to take into account which
// are defined in this article here:
// http://blogs.msdn.com/b/suzcook/archive/2003/05/29/57143.aspx
// * This will put the plugin assemblies in the 'Load' context
// This works but requires a 'probing' folder be defined in the web.config
foreach (var a in
ShadowCopyFolder
.GetFiles("*.dll", SearchOption.AllDirectories)
.Select(x => AssemblyName.GetAssemblyName(x.FullName))
.Select(x => Assembly.Load(x.FullName)))
{
BuildManager.AddReferencedAssembly(a);
}
// * This will put the plugin assemblies in the 'LoadFrom' context
// This works but requires a 'probing' folder be defined in the web.config
// This is the slowest and most error prone version of the Load contexts.
//foreach (var a in
// ShadowCopyFolder
// .GetFiles("*.dll", SearchOption.AllDirectories)
// .Select(plug => Assembly.LoadFrom(plug.FullName)))
//{
// BuildManager.AddReferencedAssembly(a);
//}
// * This will put the plugin assemblies in the 'Neither' context ( i think )
// This nearly works but fails during view compilation.
// This DOES work for resolving controllers but during view compilation which is done with the RazorViewEngine,
// the CodeDom building doesn't reference the plugin assemblies directly.
//foreach (var a in
// ShadowCopyFolder
// .GetFiles("*.dll", SearchOption.AllDirectories)
// .Select(plug => Assembly.Load(File.ReadAllBytes(plug.FullName))))
//{
// BuildManager.AddReferencedAssembly(a);
//}
}
}
}
<!-- AddThis Button BEGIN --><div class="addthis_toolbox addthis_default_style "><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a><a class="addthis_counter addthis_bubble_style"></a></div><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=nopsolutions"></script><!-- AddThis Button END -->
nopcommerce 4.1 core 插件 相关1的更多相关文章
- TeamCity : .NET Core 插件
笔者在<TeamCity : 配置 Build 过程>一文中提到 "TeamCity 内置支持几乎所有的 build 类型".在当今这个软件语言和各种框架飞速发展的时代 ...
- 2.1 -1.0 Xcode(发布时间、使用、快捷键、插件相关)
本文并非最终版本,如有更新或更正会第一时间置顶,联系方式详见文末 如果觉得本文内容过长,请前往本人 “简书” 1.0 Xcode 发布时间 版本 iOS 版本 手机 日期 特殊介绍 Xcode 3.1 ...
- NopCommerce架构分析之四----插件机制
NopCommerce支持灵活的插件机制,所谓Web系统插件,其实也就是可以像原系统的一部分一样使用. Web系统的使用方式就是客户端发送一个请求,服务端进行解析.在asp.net MVC中对客户请求 ...
- FastAdmin CMS 插件相关文章收集(2018-08-16)
FastAdmin CMS 插件相关文章收集(2018-08-16) CMS内容管理系统(含小程序) 介绍 https://www.fastadmin.net/store/cms.html CMS内容 ...
- Cordova插件相关常用命令
一,插件相关常用命令 1,查看所有已经安装的插件 1 cordova plugin ls 2,安装插件(以camera插件为例) 1 cordova plugin add cordova-plug ...
- nopcommerce插件相关
注意Description.txt中,以下字段必须配置当前可用.我抄人家代码的时候,人家是3.4 我也配成3.4,结果我的nop是3.7的,后台半天显示不出来插件,浪费了一下午.
- NopCommerce用.net core重写ef
最近看了NopCommerce源码,用core学习着写了一个项目,修改的地方记录下.项目地址 NopCommerce框架出来好久了.18年的第一季度 懒加载出来后也会全部移动到.net core.那么 ...
- 【原创】MVC项目中使用JQuery的upladify图片上传插件相关问题的解决方案
一. 关于Uploadify Uploadify是一个jQuery插件,你可以很容易的为你的网站添加多个文件上传功能.有两个不同的版本(HTML5和Flash)允许你灵活选择为您的网站和回退方法正确实 ...
- ASP.NET MVC 下使用支付宝支付接口 以及 ASP.NET Core 下相关改造支付
通过nuget首先引用AopSdk.dll 包 下面写的是 Asp.Net MVC 下相关的支付接口 APP支付 配置客户端相关的参数,配置成自己的代码就可以了 private string APPI ...
随机推荐
- 错误模块“AspNetCoreModuleV2"解决
如图 HTTP 错误 500.21 - Internal Server Error 处理程序"aspNetCore"在其模块列表中有一个错误模块"AspNetCoreMo ...
- VBoxManage安装
扩展包的版本需要与VirtualBox的版本一致,通过帮助可以查看VirtualBox的版本信息,然后在http://download.virtualbox.org/virtualbox/寻找对应的版 ...
- luogu准备复习(学习)题单
矩阵乘法 P1306 exbsgs P4195 网络流(割点) P1345 主席树 P3302
- 一键安装Lnmp教程
LNMP一键安装包 系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要3GB以上硬盘剩余空间 128M以上内存,Xen的需要有SWAP ...
- hadoop之数据压缩与数据格式
* 注:本文原创,转载请注明出处,本人保留对未注明出处行为的责任追究. a.数据压缩 优点: 1.节省本地空间 2.节省带宽 缺点: 花时间 1.MR中允许进行数据压缩的地方有三个: 1)input起 ...
- linux shell实战之知识体系
1.认识GUN/bash shell 梳理清楚硬件,内核及模块,shell之间的关系:熟悉GUN的bash以及bash shell的功能:学习shell的通配符 2.shell 的变量 变量的设置,取 ...
- js在数组中查找是否存在某一个数值
目前想到的方法有这么几个 1.indexOf() -> ES5 const array = ['apple', 'banance', 'orange'] array.indexOf('appl ...
- Golang安装与命令
1. 安装 Windows - https://golang.org/dl/ 下载msi安装包,点击安装即可.安装后cmd运行go version弹出版本号即安装成功. 2. 命令行 生成exe文件 ...
- python 数据分析基础
安装Python基础的几个数据分析库: pip install pandas pip install numpy pip install scipy pip install scikit-surpri ...
- 规则引擎 - (三)BOM工程(上)
建工程并关联xom工程 1.新建——>项目——>规则项目——>标准规则项目. 项目命名,下一步. 在xom设置中选择之前建好的xom工程,下一步. 工程没用到xsd,不选择,下一步. ...