Esempio n. 1
0
		/// <summary>
		/// 	Loads the <paramref name = "plugIn" /> (calling its <see cref = "IPlugIn.LoadPlugIn" /> method) and
		/// 	adds it to the <see cref = "Plugins" /> dictionary for access by other services.
		/// </summary>
		/// <param name = "plugIn">The plugin to load.</param>
		/// <exception cref = "ArgumentNullException">If <paramref name = "plugIn" /> is null.</exception>
		public void LoadPlugIn(IPlugIn plugIn)
		{
			if (plugIn == null)
			{
				throw new ArgumentNullException("plugIn");
			}

			plugIn.LoadPlugIn(this);
		    var type = plugIn.GetType();
		    _plugins.Add(type, plugIn);
            _container.Bind<IPlugIn>().To(type).InSingletonScope().Named(type.FullName);
        }
        /// <summary>
        ///     Loads the <paramref name = "plugIn" /> (calling its <see cref = "IPlugIn.LoadPlugIn" /> method) and
        ///     adds it to the <see cref = "Plugins" /> dictionary for access by other services.
        /// </summary>
        /// <param name = "plugIn">The plugin to load.</param>
        /// <exception cref = "ArgumentNullException">If <paramref name = "plugIn" /> is null.</exception>
        public void LoadPlugIn(IPlugIn plugIn)
        {
            if (plugIn == null)
            {
                throw new ArgumentNullException("plugIn");
            }

            //Services核心服务会从这里传入插件!!查看类PluginLoaderBase的实现
            plugIn.LoadPlugIn(this);
            _plugins.Add(plugIn.GetType(), plugIn);
            //_container.AddComponent(plugIn.GetType().FullName, typeof(IPlugIn), plugIn.GetType());

            //插件加载后,立刻加入容器
            var _builder = new ContainerBuilder();

            //_builder.Register();
            _builder.RegisterType(plugIn.GetType()).As <IPlugIn>();
            _builder.Update(_container);
            //  _builder.Update(_container);
        }