HRESULT ComTestStoreService::EndChangeRole( 
    /* [in] */ IFabricAsyncOperationContext *context,
    /* [retval][out] */ IFabricStringResult **serviceEndpoint)
{
    if (context == NULL || serviceEndpoint == NULL) { return E_POINTER; }

    CheckForReportFaultsAndDelays(testStoreService_.GetPartition(), ApiFaultHelper::Service, L"endchangerole");

    HRESULT hr = ComCompletedAsyncOperationContext::End(context);
    if (FAILED(hr)) return hr;

    ComPointer<IFabricStringResult> stringResult = make_com<ComStringResult,IFabricStringResult>(testStoreService_.ServiceLocation);
    *serviceEndpoint = stringResult.DetachNoRelease();
    return S_OK;
}
    HRESULT ComReplicator::OpenOperation::End(
        __in IFabricAsyncOperationContext * context, 
        __out IFabricStringResult **replicationEndpoint)
    {
        if (replicationEndpoint == NULL) { return E_POINTER; }
        *replicationEndpoint = NULL;

        ComPointer<ComReplicator::OpenOperation> asyncOperation(
            context, CLSID_ComReplicator_OpenOperation);

        HRESULT hr = asyncOperation->ComReplicator::BaseOperation::End();
        if (FAILED(hr)) { return hr; }
    
        ComPointer<IFabricStringResult> stringResult = make_com<ComStringResult, IFabricStringResult>(asyncOperation->replicationEndpoint_);
        *replicationEndpoint = stringResult.DetachNoRelease();
        return S_OK;
    }
HRESULT ComInfrastructureServiceAgentFactory::CreateFabricInfrastructureServiceAgent(
    /* [in] */ __RPC__in REFIID riid,
    /* [out, retval] */ __RPC__deref_out_opt void ** fabricInfrastructureServiceAgent)
{
    if (riid != IID_IFabricInfrastructureServiceAgent) { return ComUtility::OnPublicApiReturn(E_NOINTERFACE); }
    if (fabricInfrastructureServiceAgent == NULL) { return ComUtility::OnPublicApiReturn(E_POINTER); }

    IInfrastructureServiceAgentPtr agentPtr;
    ErrorCode error = impl_->CreateInfrastructureServiceAgent(agentPtr);

    if (!error.IsSuccess()) 
    {
        return ComUtility::OnPublicApiReturn(error.ToHResult());
    }

    ComPointer<IFabricInfrastructureServiceAgent> agentCPtr = WrapperFactory::create_com_wrapper(agentPtr);

    *fabricInfrastructureServiceAgent = agentCPtr.DetachNoRelease();

    return ComUtility::OnPublicApiReturn(S_OK);
}