internal SafeCommandListHandle _handle;
private List<VoiceCommand> _list;
private VcCmdListCb _callback;
+ private int _index;
/// <summary>
/// The public constructor.
throw ExceptionFactory.CreateException(error);
}
_handle = handle;
+ _list = new List<VoiceCommand>();
+ _index = 0;
}
internal VoiceCommandList(SafeCommandListHandle handle)
{
_handle = handle;
+ _index = 0;
+
+ _list = new List<VoiceCommand>();
+ _callback = (IntPtr vcCommand, IntPtr userData) =>
+ {
+ SafeCommandHandle cmdHandle = new SafeCommandHandle(vcCommand);
+ cmdHandle._ownership = false;
+ _list.Add(new VoiceCommand(cmdHandle));
+ return true;
+ };
+ ErrorCode error = VcCmdListForeachCommands(_handle, _callback, IntPtr.Zero);
+ if (error != ErrorCode.None)
+ {
+ Log.Error(LogTag, "GetAllCommands Failed with error " + error);
+ throw ExceptionFactory.CreateException(error);
+ }
}
/// <summary>
{
SafeCommandHandle current;
ErrorCode error = VcCmdListGetCurrent(_handle, out current);
- if (error != ErrorCode.None)
+ if (ErrorCode.None != error)
{
Log.Error(LogTag, "Current Failed with error " + error);
return null;
}
- current._ownership = false;
- return new VoiceCommand(current);
+
+ return _list[_index];
}
}
Log.Error(LogTag, "Add Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
+
+ _list.Add(command);
}
/// <summary>
Log.Error(LogTag, "Remove Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
+
+ _list.Remove(command);
}
/// <summary>
/// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
public IEnumerable<VoiceCommand> GetAllCommands()
{
- _list = new List<VoiceCommand>();
+ List<VoiceCommand> commandList = new List<VoiceCommand>();
_callback = (IntPtr vcCommand, IntPtr userData) =>
{
SafeCommandHandle handle = new SafeCommandHandle(vcCommand);
handle._ownership = false;
- _list.Add(new VoiceCommand(handle));
+ commandList.Add(new VoiceCommand(handle));
return true;
};
ErrorCode error = VcCmdListForeachCommands(_handle, _callback, IntPtr.Zero);
public void First()
{
ErrorCode error = VcCmdListFirst(_handle);
- if (error != ErrorCode.None)
+ if (ErrorCode.None != error)
{
Log.Error(LogTag, "First Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
+ _index = 0;
}
/// <summary>
public void Last()
{
ErrorCode error = VcCmdListLast(_handle);
- if (error != ErrorCode.None)
+ if (ErrorCode.None != error)
{
Log.Error(LogTag, "Last Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
+ _index = Count - 1;
}
/// <summary>
public void Next()
{
ErrorCode error = VcCmdListNext(_handle);
- if (error != ErrorCode.None)
+ if (ErrorCode.None != error)
{
Log.Error(LogTag, "Next Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
+ _index++;
}
/// <summary>
public void Previous()
{
ErrorCode error = VcCmdListPrev(_handle);
- if (error != ErrorCode.None)
+ if (ErrorCode.None != error)
{
Log.Error(LogTag, "Previous Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
+ _index--;
}
}
}