コード例 #1
0
 /****************************************************************************************************
  * 
  ****************************************************************************************************/
 /// <summary>
 /// Calls the handler for the command
 /// </summary>
 public void DispatchCommand(ISyncCommand command)
 {
     { var arg = command as AddEntryCommand;     if (arg != null) { _handler.AddValue    (arg.TrackIndex, arg.TrackEntry); return; } }
     { var arg = command as RemoveEntryCommand;  if (arg != null) { _handler.DeleteValue (arg.TrackIndex, arg.RowIndex);   return; } }
     { var arg = command as SetRowIndexCommand;  if (arg != null) { _handler.SetRowIndex (arg.RowIndex);                   return; } }
     { var arg = command as SetPauseCommand;     if (arg != null) { _handler.SetPause    (arg.IsPaused);                   return; } }
     { var arg = command as ExportCommand;       if (arg != null) { _handler.Export      ();                               return; } }
     throw new SyncException(string.Format("Unknown Sync Command: {0}", command.GetType().Name));
 }
コード例 #2
0
 /****************************************************************************************************
  * Serialization
  ****************************************************************************************************/
 public void SerializeCommand(ISyncCommand command)
 {
     switch (command.Id)
     {
         case CommandId.RequestTrack:
         {
             Write((byte)command.Id);
             Write((command as RequestTrackCommand).TrackName);
             break;
         }
         case CommandId.SetRowIndex:
         {
             Write((byte)command.Id);
             Write((command as SetRowIndexCommand).RowIndex);
             break;
         }
         default:
             throw new SyncException(string.Format("Unable to serialize sync command: {0} ", command.Id));
     }
 }