private void TransmitInternal(
string irCode,
CodeFormat? codeFormat,
int? repeatCount,
int? inactivityWaitTime,
Emitter? emitter)
{
//This is kind of hackish...
codeFormat = codeFormat ?? _defaultCodeFormat;
repeatCount = repeatCount ?? _defaultRepeatCount;
inactivityWaitTime = inactivityWaitTime ?? _defaultInactivityWaitTime;
emitter = emitter ?? _defaultEmitter;
if (irCode == null)
{
throw new ArgumentNullException("irCode", "irCode cannot be null");
}
if (irCode.Length == 0)
{
throw new ArgumentException("irCode", "irCode cannot be empty");
}
if (repeatCount < 0)
{
throw new ArgumentOutOfRangeException("repeatCount", "repeatCount cannot be negative");
}
if (inactivityWaitTime < 0)
{
throw new ArgumentOutOfRangeException("inactivityWaitTime",
"inactivityWaitTime cannot be less than TimeSpan.Zero");
}
using (var evt = new ManualResetEvent(false))
{
if (false == UUIRTTransmitIR(
DriverHandle,
emitter.Value.GetZoneForEmitter() + irCode,
(int)codeFormat.Value,
repeatCount.Value,
inactivityWaitTime.Value,
evt.Handle,
IntPtr.Zero,
IntPtr.Zero))
{
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
}
evt.WaitOne();
}
}