diff options
Diffstat (limited to 'src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp')
| -rw-r--r-- | src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp b/src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp new file mode 100644 index 00000000..01750b4b --- /dev/null +++ b/src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | #include "BalBaseBAFunctions.h" | ||
| 5 | #include "BalBaseBAFunctionsProc.h" | ||
| 6 | |||
| 7 | const LPCWSTR STRING_VARIABLE = L"AString"; | ||
| 8 | const LPCWSTR NUMBER_VARIABLE = L"ANumber"; | ||
| 9 | |||
| 10 | class CBafRelatedBundleVariableTesting : public CBalBaseBAFunctions | ||
| 11 | { | ||
| 12 | public: // IBAFunctions | ||
| 13 | |||
| 14 | |||
| 15 | public: //IBootstrapperApplication | ||
| 16 | virtual STDMETHODIMP OnDetectRelatedBundle( | ||
| 17 | __in_z LPCWSTR wzBundleId, | ||
| 18 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | ||
| 19 | __in_z LPCWSTR wzBundleTag, | ||
| 20 | __in BOOL fPerMachine, | ||
| 21 | __in LPCWSTR wzVersion, | ||
| 22 | __in BOOL fMissingFromCache, | ||
| 23 | __inout BOOL* pfCancel | ||
| 24 | ) | ||
| 25 | { | ||
| 26 | |||
| 27 | HRESULT hr = S_OK; | ||
| 28 | LPWSTR wzValue = NULL; | ||
| 29 | |||
| 30 | hr = BalGetRelatedBundleVariable(wzBundleId, STRING_VARIABLE, &wzValue); | ||
| 31 | |||
| 32 | ExitOnFailure(hr, "Failed to get related bundle string variable."); | ||
| 33 | |||
| 34 | if (wzValue) | ||
| 35 | { | ||
| 36 | BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: AString = %ws", wzValue); | ||
| 37 | } | ||
| 38 | |||
| 39 | hr = BalGetRelatedBundleVariable(wzBundleId, NUMBER_VARIABLE, &wzValue); | ||
| 40 | |||
| 41 | if (wzValue) | ||
| 42 | { | ||
| 43 | BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: ANumber = %ws", wzValue); | ||
| 44 | } | ||
| 45 | |||
| 46 | hr = __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel); | ||
| 47 | LExit: | ||
| 48 | ReleaseStr(wzValue); | ||
| 49 | return hr; | ||
| 50 | } | ||
| 51 | private: | ||
| 52 | |||
| 53 | |||
| 54 | public: | ||
| 55 | // | ||
| 56 | // Constructor - initialize member variables. | ||
| 57 | // | ||
| 58 | CBafRelatedBundleVariableTesting( | ||
| 59 | __in HMODULE hModule, | ||
| 60 | __in IBootstrapperEngine* pEngine, | ||
| 61 | __in const BA_FUNCTIONS_CREATE_ARGS* pArgs | ||
| 62 | ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) | ||
| 63 | { | ||
| 64 | } | ||
| 65 | |||
| 66 | // | ||
| 67 | // Destructor - release member variables. | ||
| 68 | // | ||
| 69 | ~CBafRelatedBundleVariableTesting() | ||
| 70 | { | ||
| 71 | } | ||
| 72 | |||
| 73 | private: | ||
| 74 | }; | ||
| 75 | |||
| 76 | |||
| 77 | HRESULT WINAPI CreateBAFunctions( | ||
| 78 | __in HMODULE hModule, | ||
| 79 | __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, | ||
| 80 | __inout BA_FUNCTIONS_CREATE_RESULTS* pResults | ||
| 81 | ) | ||
| 82 | { | ||
| 83 | HRESULT hr = S_OK; | ||
| 84 | CBafRelatedBundleVariableTesting* pBAFunctions = NULL; | ||
| 85 | IBootstrapperEngine* pEngine = NULL; | ||
| 86 | |||
| 87 | hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine); | ||
| 88 | ExitOnFailure(hr, "Failed to initialize Bal."); | ||
| 89 | |||
| 90 | pBAFunctions = new CBafRelatedBundleVariableTesting(hModule, pEngine, pArgs); | ||
| 91 | ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CBafRelatedBundleVariableTesting object."); | ||
| 92 | |||
| 93 | pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; | ||
| 94 | pResults->pvBAFunctionsProcContext = pBAFunctions; | ||
| 95 | pBAFunctions = NULL; | ||
| 96 | |||
| 97 | LExit: | ||
| 98 | ReleaseObject(pBAFunctions); | ||
| 99 | ReleaseObject(pEngine); | ||
| 100 | |||
| 101 | return hr; | ||
| 102 | } | ||
