private void ThrowIfNotOurs(DigitalSignalProvider provider) { if (!_providers.Contains(provider)) { throw new ArgumentException("Specified Provider is not connected to this DigitalSignal.", nameof(provider)); } }
private bool AreMultipleProvidersActive(DigitalSignalProvider changeProvider) { return(_providers .Where(p => p.Level != DigitalLevel.Floating) .Except(new[] { changeProvider }) .Any()); }
private void ThrowIfMultipleProvidersActive(DigitalSignalProvider changeProvider) { if (AreMultipleProvidersActive(changeProvider)) { throw new DigitalSignalConflictException("Multiple DigitalSignalProviders are active on: " + Name); } }
internal void Attach(DigitalSignalProvider provider) { if (_providers.Contains(provider)) { throw new ArgumentException( "Specified Provider is already connected.", nameof(provider)); } _providers.Add(provider); }
internal void OnNewProviderValue(DigitalSignalProvider provider) { ThrowIfNotOurs(provider); ThrowIfMultipleProvidersActive(provider); if (Level != provider.Level) { _level = provider.Level; NotifyOnChanged(provider); } }
internal void OnNewProviderValue(DigitalSignalProvider provider) { if (!_providers.Contains(provider)) { throw new ArgumentException("Specified Provider is not connected to this DigitalSignal.", nameof(provider)); } ThrowIfMultipleProvidersActive(provider); if (Level != provider.Level) { _level = provider.Level; NotifyOnChanged(provider); } }
private void NotifyOnChanged(DigitalSignalProvider provider) { OnChanged?.Invoke(this, new DigitalLevelChangedEventArgs(provider, Level)); }
public DigitalLevelChangedEventArgs(DigitalSignalProvider provider, DigitalLevel level) { Provider = provider; Level = level; }