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 ...
随机推荐
- 打包加载 AssetBundle
1.先创建Asset序列化(单个文件夹所在文件夹路径,会遍历这个文件夹所有的Prefab,所有的Prefab名字不能重复,必须保证名字得唯一性),配置好ConfigAB表 /* ######### # ...
- 关于matplotlib绘制直方图偏移的问题
在使用pyplot绘制直方图的时候我发现了一个问题,在给函数.hist()传参的时候,如果传入的组数不是刚刚好(就是说这个组数如果是使用(最大值-最小值)/组距计算出来,而这个数字不是整除得来而是取整 ...
- Swagger和Postman的配置和使用
Swagger 1. 配置 pom文件添加swagger依赖,注意版本,2.8.0可以使用 <dependency> <groupId>io.springfox</gro ...
- Selenium常见问题
1.使用python打开Chrome浏览器时,出现Chrome正受到自动测试软件的控制的提示 解决: 在浏览器配置里加个参数,忽略掉这个警告提示语,disable_infobars option = ...
- foreach循环里不能remove/add元素的原理
foreach循环 foreach循环(Foreach loop)是计算机编程语言中的一种控制流程语句,通常用来循环遍历数组或集合中的元素.Java语言从JDK 1.5.0开始引入forea ...
- Error: EACCES: permission denied, mkdir '......node-sass/build'错误解决方案
安装node-sass时出现一下错误: gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir ...
- SAM宏观生态学空间分析帮助文档
宏观生态学分析软件帮助文档: 引言: 该软件是由布鲁塞尔..大学开发,目的是提供一个综合的空间分析计算平台,主要针对的是宏观生态学数据.该软件可以从网站...上自由获取,该软件的主要特征以及发表在20 ...
- python之做一个简易的翻译器(一)
平时经常在网上翻译一些单词,突发奇想,可不可以直接调某些免费翻译网站的接口呢?然后做一个图形界面的翻译小工具?下面开始实践 1.先找一下有哪些免费翻译的接口 百度了一下关键字“免费翻译接口”,然后找到 ...
- warning C4828问题的处理
在QT的一些项目中,有时候会出现如下警告 warning C4828: 文件包含在偏移 0x215 处开始的字符,该字符在当前源字符集中无效(代码页 65001). (编译源文件 XXXXXXcpp) ...
- mysql Access denied for user root @localhost (using password:YES)错误
C:\AppServ\MySQL> mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'r ...