private void UpdateWidget(Widget widget) { if (widget.Dependencies == null || !widget.Dependencies.Any()) { widget.Update(); return; } var parameters = new object[widget.Dependencies.Count()]; int index = 0; foreach (Type dependencyType in widget.Dependencies) { if (!this.availableDependencies.ContainsKey(dependencyType)) { // If you get an exception here first check the InitialiseSupportedDependenciesArray method. throw new NotSupportedException( string.Format( CultureInfo.CurrentCulture, "The requested dependency {0} for the widget {1} is not supported.", dependencyType.Name, widget.Name)); } parameters[index++] = this.availableDependencies[dependencyType]; } widget.Update(parameters); }
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); }