public static IDownloader Create( UpdaterConfiguration configuration )
        {
            IDownloader downloader = null;

            #region Create the IDownloader provider

            //  use the GenericFactory to actually create the instance
            downloader = (IDownloader)GenericFactory.Create( configuration.Downloader.Assembly, configuration.Downloader.Type );

            try
            {
                downloader.Init( configuration.Downloader.Config );
            }
            catch( Exception e )
            {
                string error = ApplicationUpdateManager.TraceWrite( e, "[DownloaderFactory.Create]", "RES_ErrorInitializingDownloader", configuration.Downloader.Type, configuration.Downloader.Assembly );
                ApplicationUpdaterException theException = new ApplicationUpdaterException( error, e );
                ExceptionManager.Publish( theException );
                throw theException;
            }

            #endregion

            return downloader;
        }
Пример #2
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += ExceptionLogHandler.LogException;

            UpdaterConfiguration updaterConfig = LoadConfig <UpdaterConfiguration>();

            using (AutoGitUpdater agu = new AutoGitUpdater(updaterConfig))
            {
                agu.Start();

                WaitForUserExit(updaterConfig.RedisConfiguration);
            }
        }
Пример #3
0
 public PostUpdater(ILogger <PostUpdater> logger
                    , IOptions <UpdaterConfiguration> configOption
                    , IMonitoredPostRepository repo
                    , IRedditClientWrapper clientWrapper
                    )
 {
     _logger           = logger;
     _config           = configOption.Value;
     _repo             = repo;
     _clientWrapper    = clientWrapper;
     _configPostMaxAge = TimeSpan.Parse(_config.MaxPostAge, new CultureInfo("en-US"));
     _logger.LogInformation("Post will be monitored for [{MonitoredTime}]", _configPostMaxAge);
     _clientWrapper.ConnectivityUpdated += ConnectivityUpdated;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationUpdater"/> class.
 /// </summary>
 public ApplicationUpdater()
 {
     try {
         XmlDocument doc         = new XmlDocument();
         string      startUpPath = this.GetType().Assembly.Location;
         startUpPath = startUpPath.Substring(0, startUpPath.LastIndexOf("\\"));
         doc.Load(Path.Combine(startUpPath, Properties.Strings.UpdaterConfigurationFile));
         UpdaterConfigurationSectionHandler ucsh = new UpdaterConfigurationSectionHandler();
         _configuration  = ucsh.Create(null, null, doc.DocumentElement);
         this.UpdateName = "CCNetConfig";
     } catch (Exception ex) {
         throw new ApplicationException(Properties.Strings.UpdaterConfigLoadErrorMessage, ex);
     }
     _updateList = new UpdateInfoList();
     _serializer = new XmlSerializer(typeof(UpdateInfo));
     _tempFiles  = new List <FileInfo> ();
 }
        /// <summary>
        /// Creates a configuration section handler.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="configContext">Configuration context object.</param>
        /// <param name="section">The section.</param>
        /// <returns>Updater Configuration</returns>
        public UpdaterConfiguration Create(object parent, object configContext, XmlElement section)
        {
            XmlSerializer        serializer = new XmlSerializer(typeof(UpdaterConfiguration));
            MemoryStream         ms         = new MemoryStream();
            UpdaterConfiguration uc         = null;

            using ( ms ) {
                byte[] buffer = System.Text.Encoding.Default.GetBytes(section.OuterXml);
                ms.Write(buffer, 0, buffer.Length);
                ms.Position = 0;
                uc          = serializer.Deserialize(ms) as UpdaterConfiguration;
            }

            if (uc.TempDirectory.Exists)
            {
                uc.TempDirectory.Delete(true);
            }
            uc.TempDirectory.Create();

            return(uc);
        }
Пример #6
0
 public AutoGitUpdater(UpdaterConfiguration config)
 {
     _config = config;
 }
        public static IValidator Create( UpdaterConfiguration configuration )
        {
            IValidator validator = null;

            #region Create the IValidator provider

            //  use generic Factory to create instance of Validator with config type/asm info
            validator = (IValidator) GenericFactory.Create( configuration.Validator.Assembly, configuration.Validator.Type );

            try
            {
                validator.Init( configuration.Validator.Config );
            }
            catch( Exception e )
            {
                string error = ApplicationUpdateManager.TraceWrite( e, "[ValidatorFactory.Create]", "RES_ErrorInitializingValidator", configuration.Validator.Type, configuration.Validator.Assembly );
                ApplicationUpdaterException theException = new ApplicationUpdaterException( error, e );
                ExceptionManager.Publish( theException );
                throw theException;
            }

            #endregion

            return validator;
        }
Пример #8
0
 internal UpdaterSourceConfiguration(UpdaterConfiguration updaterConfiguration, Action <IUpdateProvider> addUpdateProvider, Action <UpdaterConfiguration> applyInheritedConfiguration)
 {
     this.updaterConfiguration        = updaterConfiguration ?? throw new ArgumentNullException(nameof(updaterConfiguration));
     this.addUpdateProvider           = addUpdateProvider ?? throw new ArgumentNullException(nameof(addUpdateProvider));
     this.applyInheritedConfiguration = applyInheritedConfiguration ?? throw new ArgumentNullException(nameof(applyInheritedConfiguration));
 }