/// <summary> /// Initializes a new instance of the <see cref="Channel{T}" /> class. /// </summary> /// <param name="invalidReadBehavior"> /// The behavior of the channel when an out-of-range read request is made. The default value is /// <see cref="InvalidReadBehavior.ReadSilence" />. /// </param> /// <param name="name"> /// The name of the channel, or <see langword="null" /> to use the name of the channel type. The default value is /// <see langword="null" />. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="invalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.Unspecified" />. /// </exception> protected Channel(InvalidReadBehavior invalidReadBehavior, String name) : base() { Identifier = Guid.NewGuid(); InvalidReadBehavior = invalidReadBehavior.RejectIf().IsEqualToValue(InvalidReadBehavior.Unspecified, nameof(invalidReadBehavior)); Name = name.IsNullOrWhiteSpace() ? GetType().Name : ToString(); OutputType = typeof(T); Status = ChannelStatus.Live; }
/// <summary> /// Initializes a new instance of the <see cref="ObjectCollectionChannel{T}" /> class. /// </summary> /// <param name="collection"> /// The collection of objects comprising the signal source. /// </param> /// <param name="invalidReadBehavior"> /// The behavior of the channel when an out-of-range read request is made. The default value is /// <see cref="InvalidReadBehavior.ReadSilence" />. /// </param> /// <param name="name"> /// The name of the channel, or <see langword="null" /> to use the name of the channel type. The default value is /// <see langword="null" />. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="collection" /> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="invalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.Unspecified" />. /// </exception> public ObjectCollectionChannel(T[] collection, InvalidReadBehavior invalidReadBehavior, String name) : base(invalidReadBehavior, name) { Collection = collection.RejectIf().IsNull(nameof(collection)); OutputLength = Collection.Length; }
/// <summary> /// Initializes a new instance of the <see cref="ObjectCollectionChannel{T}" /> class. /// </summary> /// <param name="collection"> /// The collection of objects comprising the signal source. /// </param> /// <param name="invalidReadBehavior"> /// The behavior of the channel when an out-of-range read request is made. The default value is /// <see cref="InvalidReadBehavior.ReadSilence" />. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="collection" /> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="invalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.Unspecified" />. /// </exception> public ObjectCollectionChannel(T[] collection, InvalidReadBehavior invalidReadBehavior) : this(collection, invalidReadBehavior, null) { return; }
/// <summary> /// Initializes a new instance of the <see cref="Channel{T}" /> class. /// </summary> /// <param name="invalidReadBehavior"> /// The behavior of the channel when an out-of-range read request is made. The default value is /// <see cref="InvalidReadBehavior.ReadSilence" />. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="invalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.Unspecified" />. /// </exception> protected Channel(InvalidReadBehavior invalidReadBehavior) : this(invalidReadBehavior, null) { return; }