Project Maintenance

This commit is contained in:
Gustave Monce
2021-08-09 20:21:09 +02:00
parent 9865ef7f79
commit 847ce0506d
411 changed files with 5922 additions and 54941 deletions
+10 -8
View File
@@ -16,7 +16,7 @@ namespace MadWizard.WinUSBNet
/// </summary>
public class USBPipeCollection : IEnumerable<USBPipe>
{
private Dictionary<byte, USBPipe> _pipes;
private readonly Dictionary<byte, USBPipe> _pipes;
internal USBPipeCollection(USBPipe[] pipes)
{
@@ -24,13 +24,16 @@ namespace MadWizard.WinUSBNet
foreach (USBPipe pipe in pipes)
{
if (_pipes.ContainsKey(pipe.Address))
{
throw new USBException("Duplicate pipe address in endpoint.");
}
_pipes[pipe.Address] = pipe;
}
}
/// <summary>
/// Returns the pipe from the collection with the given pipe address
/// Returns the pipe from the collection with the given pipe address
/// </summary>
/// <param name="pipeAddress">Address of the pipe to return</param>
/// <returns>The pipe with the given pipe address</returns>
@@ -40,9 +43,11 @@ namespace MadWizard.WinUSBNet
{
get
{
USBPipe pipe;
if (!_pipes.TryGetValue(pipeAddress, out pipe))
if (!_pipes.TryGetValue(pipeAddress, out USBPipe pipe))
{
throw new IndexOutOfRangeException();
}
return pipe;
}
}
@@ -50,7 +55,7 @@ namespace MadWizard.WinUSBNet
private class UsbPipeEnumerator : IEnumerator<USBPipe>
{
private int _index;
private USBPipe[] _pipes;
private readonly USBPipe[] _pipes;
public UsbPipeEnumerator(USBPipe[] pipes)
{
@@ -68,7 +73,6 @@ namespace MadWizard.WinUSBNet
{
return _pipes[_index];
}
catch (IndexOutOfRangeException)
{
throw new InvalidOperationException();
@@ -83,7 +87,6 @@ namespace MadWizard.WinUSBNet
}
}
object IEnumerator.Current
{
get
@@ -102,7 +105,6 @@ namespace MadWizard.WinUSBNet
{
_index = -1;
}
}
private USBPipe[] GetPipeList()