/// <summary> /// Attach a command to the factory, send request to server. /// </summary> /// <param name="command"> /// The command that is to be attached and/or sent. /// </param> /// <returns> /// Returns <c>true</c> on success. /// </returns> /// <remarks> /// Normally this method is not invoked directly, but it get's called /// automatically from <see cref="ZIMapCommand.Queue"/>. This is also /// the case for commands that were explicitly detached from the /// factory. /// <para /> /// If the command is already attached to the factory it will first be /// detached. Then the command will be attached to the factory and will /// be placed at the beginning of the commands list. If the command /// is not in the state <see cref="ZIMapCommand.CommandState.Queued"/> /// it will be queued (in other words: the request will be sent to /// the server). /// <para /> /// Usually commands get never explicitly detached from the factory that /// owns them until they are disposed, see <see cref="DetachCommand"/>. /// An error of type <see cref="ZIMapException.Error.InvalidArgument"/> /// is raised if the command was created by another factory instance. /// </remarks> public bool QueueCommand(ZIMapCommand command) { if(GetCommands() == null) return false; // parent closed if(command.Parent != Parent) // my command? { RaiseError(ZIMapException.Error.InvalidArgument, "wrong owner"); return false; } commands.Remove(command); // may fail: ok commands.Add(command); // move to start if(command.State == ZIMapCommand.CommandState.Queued) return true; // no change return command.Queue(); // tell the command }