Exemplo n.º 1
0
  ICountable::Pointer
  Expressions::GetAsICountable(Object::Pointer var, Expression::Pointer expression)
  {
    ICountable::Pointer countable(var.Cast<ICountable>());
    if (!countable.IsNull())
    {
      return countable;
    }
    else
    {
      IAdapterManager::Pointer manager = Platform::GetServiceRegistry().GetServiceById<IAdapterManager>("org.blueberry.service.adaptermanager");
      Object::Pointer result;
      Poco::Any any(manager->GetAdapter(var, ICountable::GetStaticClassName()));
      if (!any.empty() && any.type() == typeid(Object::Pointer))
      {
        result = Poco::AnyCast<Object::Pointer>(any);
      }

      if (result)
      {
        countable = result.Cast<ICountable>();
      }

      if (manager->QueryAdapter(var->GetClassName(), ICountable::GetStaticClassName()) == IAdapterManager::NOT_LOADED)
        return ICountable::Pointer();

      throw CoreException("The variable is not countable", expression->ToString());
    }
  }
Exemplo n.º 2
0
Poco::Any PlatformObject::GetAdapter(const std::string& adapter)
{
  IAdapterManager::Pointer adapterManager = Platform::GetServiceRegistry().GetServiceById<IAdapterManager>(Runtime::ADAPTER_SERVICE_ID);
  if (adapterManager)
    return adapterManager->GetAdapter(Object::Pointer(this), adapter);

  return Poco::Any();
}