SmartPointer<IElementReference> CommandService::RegisterElementForCommand( const SmartPointer<ParameterizedCommand>& command, const SmartPointer<UIElement>& element) { if (!command->GetCommand()->IsDefined()) { throw NotDefinedException( "Cannot define a callback for undefined command " + command->GetCommand()->GetId()); } if (element.IsNull()) { throw NotDefinedException("No callback defined for command " + command->GetCommand()->GetId()); } QHash<QString, QString> paramMap = command->GetParameterMap(); QHash<QString, Object::Pointer> parms; for (QHash<QString, QString>::const_iterator i = paramMap.begin(); i != paramMap.end(); ++i) { Object::Pointer value(new ObjectString(i.value())); parms.insert(i.key(), value); } IElementReference::Pointer ref(new ElementReference(command->GetId(), element, parms)); RegisterElement(ref); return ref; }
SmartPointer<const ExecutionEvent> HandlerService::CreateExecutionEvent( const SmartPointer<const ParameterizedCommand>& command, const SmartPointer<const UIElement>& trigger) { ExecutionEvent::Pointer event( new ExecutionEvent(command->GetCommand(), command->GetParameterMap(), trigger, Object::Pointer(GetCurrentState()))); return event; }