Esempio n. 1
0
        /// <summary>
        /// Implementation of <see cref="IModuleTypeLoader.LoadModuleType"/>
        /// </summary>
        public void LoadModuleType(ModuleInfo moduleInfo)
        {
            var match = Regex.Match(moduleInfo.Ref, RegexExpression);

            if (!match.Success)
            {
                return;
            }

            var packageInfo = new PackageMetadata(
                match.Groups["PACKAGE"].Value,
                new Version(
                    Convert.ToInt32(match.Groups["MAJOR"].Value),
                    Convert.ToInt32(match.Groups["MINOR"].Value),
                    Convert.ToInt32(match.Groups["PATCH"].Value)),
                match.Groups["SUFFIX"].Value);

            Exception error = null;

            try
            {
                ModuleDownloadProgressChanged?.Invoke(this, new ModuleDownloadProgressChangedEventArgs(moduleInfo, 1000000, 2000000));
                this.packageManagingService.EnsurePackageLoaded(packageInfo);
            }
            catch (Exception e)
            {
                this.logger.Log($"[{nameof(PackageModuleTypeLoader)}.{nameof(LoadModuleType)}(scheme:'{scheme}', moduleRef:'{moduleInfo.Ref}')] - An error occurs during the loading of the package : {ExtractException(e)}", Category.Exception, Priority.High);
                error = e;
            }

            ModuleDownloadProgressChanged?.Invoke(this, new ModuleDownloadProgressChangedEventArgs(moduleInfo, 2000000, 2000000));
            LoadModuleCompleted?.Invoke(this, new LoadModuleCompletedEventArgs(moduleInfo, error));
        }
Esempio n. 2
0
 /// <summary>
 /// Loads the specified modules.
 /// </summary>
 /// <param name="moduleInfos"><see cref="ModuleInfo"/>.</param>
 protected virtual void LoadModules(IEnumerable <ModuleInfo> moduleInfos)
 {
     foreach (var moduleInfo in moduleInfos)
     {
         if (moduleInfo.State == ModuleState.NotStarted)
         {
             try
             {
                 moduleInfo.State = ModuleState.Initializing;
                 ModuleInitializer.Initialize(moduleInfo);
                 moduleInfo.State = ModuleState.Initialized;
                 LoadModuleCompleted?.Invoke(this, new LoadModuleCompletedEventArgs(moduleInfo, null));
             }
             catch (Exception ex)
             {
                 LoadModuleCompleted?.Invoke(this, new LoadModuleCompletedEventArgs(moduleInfo, ex));
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Raises the <see cref="LoadModuleCompleted"/> event.
 /// </summary>
 /// <param name="moduleInfo">The <see cref="IModuleInfo"/> that was just loaded.</param>
 /// <param name="ex">An <see cref="Exception"/> if any that was thrown during the loading of the <see cref="IModule"/></param>
 protected void RaiseLoadModuleCompleted(IModuleInfo moduleInfo, Exception ex = null)
 {
     LoadModuleCompleted?.Invoke(this, new LoadModuleCompletedEventArgs(moduleInfo, ex));
 }
Esempio n. 4
0
 void RaiseLoadModuleCompleted(LoadModuleCompletedEventArgs e)
 {
     LoadModuleCompleted?.Invoke(this, e);
 }