Exemple #1
0
		public SyncContext(
			IServiceProvider provider,
			IStatisticsContainer statsContainer,
			Func<bool> isSyncCancelled)
		{
			if (statsContainer == null)
				throw new ArgumentNullException("statsContainer");

			_provider = provider;
			_statsContainer = statsContainer;
			_isSyncCancelled = isSyncCancelled;
		}
Exemple #2
0
		public EndSyncEventArgs(
			[NotNull] IStatisticsContainer statisticsContainer,
			SyncResult result,
			Exception exception)
		{
			if (statisticsContainer == null)
				throw new ArgumentNullException("statisticsContainer");

			_statisticsContainer = statisticsContainer;
			_exception = exception;
			_result = result;
		}
        public EndSyncEventArgs(
            [NotNull] IStatisticsContainer statisticsContainer,
            SyncResult result,
            Exception exception)
        {
            if (statisticsContainer == null)
            {
                throw new ArgumentNullException("statisticsContainer");
            }

            _statisticsContainer = statisticsContainer;
            _exception           = exception;
            _result = result;
        }
        public SyncContext(
            IServiceProvider provider,
            IStatisticsContainer statsContainer,
            Func <bool> isSyncCancelled)
        {
            if (statsContainer == null)
            {
                throw new ArgumentNullException("statsContainer");
            }

            _provider        = provider;
            _statsContainer  = statsContainer;
            _isSyncCancelled = isSyncCancelled;
        }
        private static void DoAsyncSync(
            Func <ISynchronizer, IStatisticsContainer> syncProc,
            IServiceProvider provider,
            SyncRequestFinishedHandler syncFinishedHandler,
            bool checkAvailability,
            SyncThreadPriority priority)
        {
            var sz = provider.GetRequiredService <ISynchronizer>();

            if (!sz.IsActive())
            {
                var thread = CreateSyncThread(
                    () =>
                {
                    try
                    {
                        var syncPerformed          = false;
                        IStatisticsContainer stats = null;
                        if (!checkAvailability || sz.IsAvailable())
                        {
                            syncPerformed = true;
                            stats         = syncProc(sz);
                        }
                        if (syncFinishedHandler != null)
                        {
                            provider.GetRequiredService <IUIShell>()
                            .CreateUIAsyncOperation()
                            .PostOperationCompleted(state => syncFinishedHandler(syncPerformed, stats), null);
                        }
                    }
                    catch (Exception ex)
                    {
                        provider.GetRequiredService <IUIShell>()
                        .CreateUIAsyncOperation()
                        .PostOperationCompleted(
//{{{-PossibleIntendedRethrow
                            state => { throw ex; }, null);
//{{{+PossibleIntendedRethrow
                    }
                },
                    priority);
                thread.Start();
            }
            else if (syncFinishedHandler != null)
            {
                syncFinishedHandler(false, null);
            }
        }
Exemple #6
0
        public static string GetFormattedValues(
            this IStatisticsContainer container,
            IServiceProvider provider)
        {
            var statsMgr = provider.GetRequiredService <IStatsFormatterManager>();
            var sb       = new StringBuilder();

            foreach (var name in container.GetStatsNames().OrderBy(nm => nm))
            {
                if (sb.Length > 0)
                {
                    sb.Append(", ");
                }
                sb.Append(statsMgr.FormatValue(
                              name,
                              container.GetTotalValue(name),
                              CultureInfo.CurrentUICulture));
            }
            return(sb.ToString());
        }
Exemple #7
0
 public static bool IsEmpty(this IStatisticsContainer container)
 {
     return(!container.GetStatsNames().Any());
 }
 public EndSyncEventArgs(
     [NotNull] IStatisticsContainer statisticsContainer,
     SyncResult result)
     : this(statisticsContainer, result, null)
 {
 }