using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace Artemis.Core { /// /// Represents a collection of input pins containing values of type /// /// The type of value the pins in this collection hold public sealed class InputPinCollection : PinCollection { #region Constructors internal InputPinCollection(INode node, string name, int initialCount) : base(node, name, initialCount) { } #endregion #region Methods /// protected override IPin CreatePin() { return new InputPin(Node, string.Empty); } #endregion #region Properties & Fields /// public override PinDirection Direction => PinDirection.Input; /// public override Type Type => typeof(T); /// /// Gets an enumerable of the pins in this collection /// public new IEnumerable> Pins => base.Pins.Cast>(); /// /// Gets an enumerable of the values of the pins in this collection /// public IEnumerable Values => Pins.Where(p => p.Value != null).Select(p => p.Value!); #endregion } /// /// Represents a collection of input pins /// public sealed class InputPinCollection : PinCollection { #region Constructors internal InputPinCollection(INode node, Type type, string name, int initialCount) : base(node, name, 0) { Type = type; // Can't do this in the base constructor because the type won't be set yet for (int i = 0; i < initialCount; i++) AddPin(); } #endregion #region Methods /// protected override IPin CreatePin() { return new InputPin(Node, Type, string.Empty); } #endregion #region Properties & Fields /// public override PinDirection Direction => PinDirection.Input; /// public override Type Type { get; } /// /// Gets an enumerable of the pins in this collection /// public new IEnumerable Pins => base.Pins.Cast(); /// /// Gets an enumerable of the values of the pins in this collection /// public IEnumerable Values => Pins.Where(p => p.Value != null).Select(p => p.Value); #endregion } }