Example #1
0
        public static ICrypt GetCrypt(string storageName, EncryptionSettings encryptionSettings)
        {
            ICrypt result = null;

            if (Builder != null)
            {
                result = ResolutionExtensions.ResolveOptional <ICrypt>(Builder, new TypedParameter(typeof(string), storageName), new TypedParameter(typeof(EncryptionSettings), encryptionSettings));
            }

            return(result ?? new FakeCrypt(storageName, encryptionSettings));
        }
        void ThreadWorks(UpdaterFlags flags, ILifetimeScope threadScope)
        {
            string  checkVersion = String.Empty, checkResult = String.Empty;
            var     application       = threadScope.Resolve <IApplicationInfo>();
            dynamic parametersService = ResolutionExtensions.ResolveOptional <ParametersService>(threadScope);
            var     updateService     = threadScope.Resolve <IUpdateService>();
            var     skip = threadScope.Resolve <ISkipVersionState>();
            var     uI   = threadScope.Resolve <IUpdaterUI>();

            try {
                logger.Info("Запрашиваем информацию о новых версиях с сервера");
                string parameters = String.Format("product.{0};edition.{1};serial.{2};major.{3};minor.{4};build.{5};revision.{6}",
                                                  application.ProductName,
                                                  application.Modification,
                                                  parametersService?.serial_number,
                                                  application.Version.Major,
                                                  application.Version.Minor,
                                                  application.Version.Build,
                                                  application.Version.Revision);

                var updateResult = updateService.checkForUpdate(parameters);
                if (flags.HasFlag(UpdaterFlags.ShowAnyway) || (updateResult.HasUpdate && !skip.IsSkipedVersion(updateResult.NewVersion)))
                {
                    uI.ShowAppNewVersionDialog(updateResult, flags);
                }
            }
            catch (Exception ex) {
                logger.Error(ex, "Ошибка доступа к серверу обновления.");
                if (flags.HasFlag(UpdaterFlags.ShowAnyway))
                {
                    uI.InteractiveMessage.ShowMessage(Dialog.ImportanceLevel.Error, "Не удалось подключиться к серверу обновлений.\nПожалуйста, повторите попытку позже.");
                }
                if (flags.HasFlag(UpdaterFlags.UpdateRequired))
                {
                    Environment.Exit(1);
                }
            }
        }
Example #3
0
 public override object GetService(Type serviceType)
 {
     return(ResolutionExtensions.ResolveOptional(this.lifetimeScope, serviceType) ?? base.GetService(serviceType));
 }