コード例 #1
0
        /// <summary>
        ///根据<paramref name="type"/>,<paramref name="instance"/>, 创建一个<see cref="XqModuleDescriptor"/>对象
        /// </summary>
        /// <param name="type">模块的类型</param>
        /// <param name="instance">模块的实例</param>
        /// <param name="isLoadedAsPlugIn">是否为外部加载</param>
        public XqModuleDescriptor(
            [NotNull] Type type,
            [NotNull] IXqModule instance,
            bool isLoadedAsPlugIn)
        {
            XqCheck.NotNull(type, nameof(type));
            XqCheck.NotNull(instance, nameof(instance));

            ///type与instance的type不一样
            if (!type.GetTypeInfo().IsAssignableFrom(instance.GetType()))
            {
                throw new ArgumentException($"Given module instance ({instance.GetType().AssemblyQualifiedName}) is not an instance of given module type: {type.AssemblyQualifiedName}");
            }

            Type             = type;
            Assembly         = type.Assembly;
            Instance         = instance;
            IsLoadedAsPlugIn = isLoadedAsPlugIn;

            _dependencies = new List <IXqModuleDescriptor>();
        }
コード例 #2
0
 public virtual void Shutdown(ApplicationShutdownContext context, IXqModule module)
 {
 }
コード例 #3
0
 /// <summary>
 /// <paramref name="module"/>在初始时,根据<see cref="ApplicationInitializationContext"/>,进行的初始化操作
 /// </summary>
 /// <param name="context">进行初始化化时的上下文</param>
 /// <param name="module">被初始化的Module</param>
 public virtual void Initialize(ApplicationInitializationContext context, IXqModule module)
 {
 }
 public override void Initialize(ApplicationInitializationContext context, IXqModule module)
 {
     (module as IOnPostApplicationInitialization)?.OnPostApplicationInitialization(context);
 }
 /// <summary>
 /// <paramref name="module"/>注销时,调用该模块的OnApplicationShutdown操作,进行注销
 /// </summary>
 /// <param name="context"></param>
 /// <param name="module"></param>
 public override void Shutdown(ApplicationShutdownContext context, IXqModule module)
 {
     (module as IOnApplicationShutdown)?.OnApplicationShutdown(context);
 }