예제 #1
0
  MimeType MimeTypeProvider::GetMimeType(const ServiceReferenceType &reference) const
  {
    MimeType result;
    if (!reference)
      return result;

    CustomMimeType *mimeType = us::GetModuleContext()->GetService(reference);
    if (mimeType != nullptr)
    {
      try
      {
        int rank = 0;
        us::Any rankProp = reference.GetProperty(us::ServiceConstants::SERVICE_RANKING());
        if (!rankProp.Empty())
        {
          rank = us::any_cast<int>(rankProp);
        }
        auto id = us::any_cast<long>(reference.GetProperty(us::ServiceConstants::SERVICE_ID()));
        result = MimeType(*mimeType, rank, id);
      }
      catch (const us::BadAnyCastException &e)
      {
        MITK_WARN << "Unexpected exception: " << e.what();
      }
      us::GetModuleContext()->UngetService(reference);
    }
    return result;
  }
예제 #2
0
파일: usServiceHooks.cpp 프로젝트: 0r/MITK
ServiceHooks::TrackedType ServiceHooks::AddingService(const ServiceReferenceType& reference)
{
  ServiceListenerHook* lh = GetModuleContext()->GetService(reference);
  try
  {
    lh->Added(coreCtx->listeners.GetListenerInfoCollection());
  }
  catch (const std::exception& e)
  {
    US_WARN << "Failed to call listener hook  #" << reference.GetProperty(ServiceConstants::SERVICE_ID()).ToString()
               << ": " << e.what();
  }
  catch (...)
  {
    US_WARN << "Failed to call listener hook  #" << reference.GetProperty(ServiceConstants::SERVICE_ID()).ToString()
               << ": unknown exception type";
  }
  return lh;
}