public USBInterface WithEndpoint(Direction direction, EndpointTransferType transferType, short maximumPacketSize, byte interval, out USBEndpoint createdEndpoint) { if (endpoints.Count == byte.MaxValue) { throw new ConstructionException("The maximal number of endpoints reached"); } createdEndpoint = new USBEndpoint(device, (byte)(endpoints.Count + 1), direction, transferType, maximumPacketSize, interval); endpoints.Add(createdEndpoint); return(this); }
public USBInterface WithEndpoint(Direction direction, EndpointTransferType transferType, short maximumPacketSize, byte interval, out USBEndpoint createdEndpoint, byte?id = null) { if (!id.HasValue && endpoints.Count == byte.MaxValue) { throw new ConstructionException("The maximal number of endpoints reached"); } var localId = id ?? (byte)(endpoints.Count + 1); if (endpoints.Any(x => x.Identifier == localId && x.Direction == direction)) { throw new ConstructionException($"Endpoint with id {localId} in direction {direction} already definied"); } createdEndpoint = new USBEndpoint(device, localId, direction, transferType, maximumPacketSize, interval); endpoints.Add(createdEndpoint); return(this); }