private void UpdateWidget(Widget widget)
{
if (widget.Dependencies == null || widget.Dependencies.None())
{
widget.Update();
return;
}
var parameters = new object[widget.Dependencies.Count()];
var index = 0;
foreach (var dependencyType in widget.Dependencies)
{
try
{
parameters[index++] = this.monitoringServices.RetrieveDependency(dependencyType);
}
catch (NotSupportedException ex)
{
// If you get an exception here first check the MonitorableDependencies.ctor method.
throw new NotSupportedException(
string.Format(
CultureInfo.CurrentCulture,
"The requested dependency {0} for the widget {1} is not supported.",
dependencyType.Name,
widget.Name), ex);
}
}
widget.Update(parameters);
}