Added prototype code for an inversion-of-control container and a progress tracking service; moved XmlHelper class from Nuclex.UserInterface to Nuclex.Support; Nuclex.Support now uses the .NET Framework's own AssemblyLoadEventArgs class if it is compiled for the full framework; fixed a bug in the Request class that would cause exceptions to not be reported if Join() was called on a Request<x> was casted to a plain Request
git-svn-id: file:///srv/devel/repo-conversion/nusu@138 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
d0fe47239e
commit
41dcfa34d0
15 changed files with 1030 additions and 6 deletions
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Nuclex.Support.Tracking;
|
||||
|
||||
namespace Nuclex.Support.Services.ProgressTracking {
|
||||
|
||||
/// <summary>Reports the progress of tracked background processes</summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This service is intended for the consumer of progress reports. It will notify
|
||||
/// subscribers when background processes start, when progress is achieved and
|
||||
/// when they finish.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Usually, this interface, together with the IProgressTrackingService interface,
|
||||
/// is provided by a single service component that tracks the progress of
|
||||
/// transactions taking place asynchronously and reports it back this way.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
interface IProgressPublishingService {
|
||||
|
||||
/// <summary>Fired when the overall progress changes</summary>
|
||||
event EventHandler<ProgressReportEventArgs> ProgressChanged;
|
||||
|
||||
/// <summary>The overall progress of all tracked background processes</summary>
|
||||
float TotalProgress { get; }
|
||||
|
||||
/// <summary>Currently active background processes</summary>
|
||||
IEnumerable<ITrackedProcess> TrackedProcesses { get; }
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Support.DependencyInjection.ProgressTracking
|
68
Source/Services/ProgressTracking/IProgressTrackingService.cs
Normal file
68
Source/Services/ProgressTracking/IProgressTrackingService.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Nuclex.Support.Tracking;
|
||||
|
||||
namespace Nuclex.Support.Services.ProgressTracking {
|
||||
|
||||
/// <summary>Allows application-wide tracking of progress</summary>
|
||||
interface IProgressTrackingService {
|
||||
|
||||
/// <summary>Tracks the progress of the specified transaction</summary>
|
||||
/// <param name="transaction">
|
||||
/// Transaction whose progress will be tracked
|
||||
/// </param>
|
||||
/// <param name="processIdentifier">
|
||||
/// Identifier unique to the tracked background process. Can be null.
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Using the process identifier allows you to track the progress of multiple
|
||||
/// transactions that are working independently of each other. This could,
|
||||
/// for example, result in multiple progress bars being displayed in a GUI.
|
||||
/// The global progress always is a combination of all transactions tracked
|
||||
/// by the service.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// A good analogy for this might be a download manager which uses several
|
||||
/// threads to download multiple sections of a file at the same time. You
|
||||
/// want a progress bar per file, but not one for each downloading thread.
|
||||
/// Specifying the name object as a process identifer, all transactions
|
||||
/// belonging to the same file would be merged into a single progress source.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The process identifier can be a string or any object. Note however that
|
||||
/// as common practice, this object's ToString() method should return
|
||||
/// something reasonable, like "Downloading xy.txt". Localization can be
|
||||
/// achieved by implementing an interface (eg. ILocalizableToString) which
|
||||
/// provides a string and some parameters - or you could return the already
|
||||
/// translated versions of the string if you prefer to have localized versions
|
||||
/// of internal assemblies.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
void Track(Transaction transaction, object processIdentifier);
|
||||
|
||||
/// <summary>Tracks the progress of the specified transaction</summary>
|
||||
/// <param name="transaction">
|
||||
/// Transaction whose progress will be tracked
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// Tracks the transaction as if it was added with the process identifier
|
||||
/// set to null.
|
||||
/// </remarks>
|
||||
void Track(Transaction transaction);
|
||||
|
||||
/// <summary>Stops tracking the specified transaction</summary>
|
||||
/// <param name="transaction">Transaction that will no longer be tracked</param>
|
||||
/// <remarks>
|
||||
/// Untracking a transaction is optional. The service will automatically
|
||||
/// remove finished transactions from its list of tracked transactions. Calling
|
||||
/// this method is only required if you drop a transaction in a way that
|
||||
/// prevents its AsyncEnded event from being fired (eg. by not executing it
|
||||
/// at all, dispite adding it to the progress tracking service).
|
||||
/// </remarks>
|
||||
void Untrack(Transaction transaction);
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Support.DependencyInjection.ProgressTracking
|
29
Source/Services/ProgressTracking/ITrackedProcess.cs
Normal file
29
Source/Services/ProgressTracking/ITrackedProcess.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Nuclex.Support.Tracking;
|
||||
|
||||
namespace Nuclex.Support.Services.ProgressTracking {
|
||||
|
||||
/// <summary>Process whose progress is being tracked</summary>
|
||||
public interface ITrackedProcess {
|
||||
|
||||
/// <summary>Fired whenever the progress of the process changes</summary>
|
||||
event EventHandler<ProgressReportEventArgs> ProgressChanged;
|
||||
|
||||
/// <summary>Unique identifier of the overall process</summary>
|
||||
/// <remarks>
|
||||
/// As a convention, using this object's ToString() method should return
|
||||
/// something usable, either a string that can be displayed in the user
|
||||
/// interface or, depending on your architecture, the object could
|
||||
/// implement certain interfaces that allow a localized version of
|
||||
/// the string to be created.
|
||||
/// </remarks>
|
||||
object ProcessIdentifier { get; }
|
||||
|
||||
/// <summary>Progress that process has achieved so far</summary>
|
||||
float CurrentProgress { get; }
|
||||
|
||||
}
|
||||
|
||||
} // namespace Nuclex.Support.DependencyInjection.ProgressTracking
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Nuclex.Support.Tracking;
|
||||
|
||||
namespace Nuclex.Support.Services.ProgressTracking {
|
||||
|
||||
#if false
|
||||
/// <summary>Tracks the progress of running background processes</summary>
|
||||
public class ProgressTrackingComponent :
|
||||
IProgressTrackingService,
|
||||
IProgressPublishingService {
|
||||
|
||||
/// <summary>Fired when the overall progress changes</summary>
|
||||
public event EventHandler<ProgressReportEventArgs> ProgressChanged;
|
||||
|
||||
/// <summary>Initializes a new progress tracking component</summary>
|
||||
public ProgressTrackingComponent() {
|
||||
}
|
||||
|
||||
/// <summary>Tracks the progress of the specified transaction</summary>
|
||||
/// <param name="transaction">
|
||||
/// Transaction whose progress will be tracked
|
||||
/// </param>
|
||||
/// <param name="processIdentifier">
|
||||
/// Identifier unique to the tracked background process. Can be null.
|
||||
/// </param>
|
||||
public void Track(Transaction transaction, object processIdentifier) {
|
||||
}
|
||||
|
||||
/// <summary>Tracks the progress of the specified transaction</summary>
|
||||
/// <param name="transaction">
|
||||
/// Transaction whose progress will be tracked
|
||||
/// </param>
|
||||
public void Track(Transaction transaction) {
|
||||
}
|
||||
|
||||
/// <summary>Stops tracking the specified transaction</summary>
|
||||
/// <param name="transaction">Transaction that will no longer be tracked</param>
|
||||
public void Untrack(Transaction transaction) {
|
||||
}
|
||||
|
||||
/// <summary>The overall progress of all tracked background processes</summary>
|
||||
public float TotalProgress {
|
||||
get { return 0.0f; }
|
||||
}
|
||||
|
||||
/// <summary>Currently active background processes</summary>
|
||||
public IEnumerable<ITrackedProcess> TrackedProcesses {
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace Nuclex.Support.Services.ProgressTracking
|
Loading…
Add table
Add a link
Reference in a new issue