public void Initialize(PluginInfo info) { pluginInfo = info; PluginConfig = JsonConvert.DeserializeObject<ConfigInfo>(info.Config); Operate.Init(); WebIoc.Register(b => b.Register(c=>new Loger(PluginIoc.Container.Resolve<ILogOperate>())).As<ILoger>().SingleInstance(), assemblyGuid, info.Status == PluginStatus.Usable); }
public void Initialize(PluginInfo info) { if (null == pluginInfo) { pluginInfo = info; RouteConfig.RegisterRoutes();//注册路由 BundleConfig.RegisterBundles();//注册css与javascript压缩 WebIoc.Register(c => c.RegisterInstance<RouteValueDictionary>(new System.Web.Routing.RouteValueDictionary(new { controller = "adminhome", action = "login",area="admin" })).Named<RouteValueDictionary>("admin")); } }
public void Initialize(PluginInfo info) { pluginInfo = info; var hostList = JsonConvert.DeserializeObject<List<ConfigInfo>>(info.Config); foreach (var host in hostList) { if (host.Name == "datas") WebIoc.Register(b => b.Register<RedisCache>(c => new RedisCache(host)).As<ICache>().SingleInstance()); WebIoc.Register(b => b.Register<RedisCache>(c => new RedisCache(host)).Named<ICache>(host.Name).SingleInstance(), guid, info.Status == PluginStatus.Usable); } WebIoc.Register(b => b.Register(c => new Session(c.ResolveNamed<ICache>("session"))).As<Sun.Core.Session.ISession>().PreserveExistingDefaults().SingleInstance(), guid, info.Status == PluginStatus.Usable); }
/// <summary> /// 保存插件信息 /// </summary> /// <param name="plugin">插件对象</param> /// <param name="filePath">保存地址</param> public void SavePluginInfo(PluginInfo plugin) { var path = Path.Combine(plugin.Path, Loader.Instance.PluginInfoFileName); if (!File.Exists(path)) File.Create(path); if (plugin.Type == PluginType.Module) File.WriteAllText(path, JsonConvert.SerializeObject(new { Guid = plugin.Guid, Type = plugin.Type, Areas = plugin.Areas, GroupName = plugin.GroupName, Name = plugin.Plugin.Name, NickName = plugin.NickName, Version = plugin.Version, Author = plugin.Author, AssemblyNames = plugin.AssemblyNames, Status = plugin.Status, Config = plugin.Config, Intro = plugin.Intro })); else { File.WriteAllText(path, JsonConvert.SerializeObject(new { Guid = plugin.Guid, Type = plugin.Type, GroupName = plugin.GroupName, Name = plugin.Plugin.Name, NickName = plugin.NickName, Version = plugin.Version, Author = plugin.Author, AssemblyNames = plugin.AssemblyNames, Status = plugin.Status, Config = plugin.Config, Intro = plugin.Intro })); } }
public void Initialize(PluginInfo info) { throw new NotImplementedException(); }
/// <summary> /// 初始化插件。 /// </summary> /// <param name="pluginDescriptor">插件描述</param> public void InitPlugin(PluginInfo pluginInfo) { //使用插件名称做为字典 KEY。 string key = pluginInfo.Plugin.Name; //不存在时才进行初始化。 if (!plugins.ContainsKey(key)) { //初始化。 try { pluginInfo.Plugin.Initialize(pluginInfo); } catch (Exception e) { pluginInfo.Status = PluginStatus.Error; FileOperate.Instance.SavePluginInfo(pluginInfo); } //增加到字典。 plugins.TryAdd(key, pluginInfo); } }
public void DeletePlugin(PluginInfo plugin) { File.Delete(plugin.Path); }