Class Dependency
Represents the base class from which all implementations of dependency relationship to an object should derive.
public abstract class Dependency : IDependency
- Inheritance
-
Dependency
- Implements
- Derived
Remarks
The implementing class of the Dependency class must monitor the dependency relationships so that when any of them changes, action will automatically be taken.
Constructors
Dependency(Func<EventHandler<WatcherEventArgs>, IEnumerable<IWatcher>>, bool)
Initializes a new instance of the Dependency class.
protected Dependency(Func<EventHandler<WatcherEventArgs>, IEnumerable<IWatcher>> watchersHandler, bool breakTieOnChanged)
Parameters
watchersHandlerFunc<EventHandler<WatcherEventArgs>, IEnumerable<IWatcher>>The function delegate that associates watchers to this dependency.
breakTieOnChangedboolif set to
trueall IWatcher instances is disassociated with this dependency after first notification of changed.
Properties
BreakTieOnChanged
Gets a value indicating whether all IWatcher instances is disassociated with this dependency after first notification of changed.
public bool BreakTieOnChanged { get; }
Property Value
- bool
trueif all IWatcher instances is disassociated with this dependency after first notification of changed; otherwise,false.
HasChanged
Gets a value indicating whether the Dependency object has changed.
public virtual bool HasChanged { get; }
Property Value
- bool
trueif the Dependency object has changed; otherwise,false.
UtcLastModified
Gets time when the dependency was last changed.
public DateTime? UtcLastModified { get; }
Property Value
- DateTime?
The time when the dependency was last changed.
Remarks
This property is measured in Coordinated Universal Time (UTC) (also known as Greenwich Mean Time).
Methods
OnDependencyChangedRaised(DependencyEventArgs)
Raises the DependencyChanged event.
protected virtual void OnDependencyChangedRaised(DependencyEventArgs e)
Parameters
eDependencyEventArgsThe DependencyEventArgs instance containing the event data.
OnWatcherChanged(object, WatcherEventArgs)
Called when this object receives a signal from one or more of the associated IWatcher.
protected virtual void OnWatcherChanged(object sender, WatcherEventArgs args)
Parameters
senderobjectThe source of the event.
argsWatcherEventArgsThe WatcherEventArgs instance containing the event data.
SetUtcLastModified(DateTime)
Marks the time when a dependency last changed.
protected void SetUtcLastModified(DateTime utcLastModified)
Parameters
utcLastModifiedDateTimeThe time when the dependency last changed.
Start()
Starts and performs the necessary dependency tasks of this instance.
public virtual void Start()
StartAsync()
Starts and performs the necessary dependency tasks of this instance.
public virtual Task StartAsync()
Returns
- Task
The task object representing the asynchronous operation.
Events
DependencyChanged
Occurs when a Dependency has changed.
public event EventHandler<DependencyEventArgs> DependencyChanged