main
cpp 87 lines 2.74 KB
Raw
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 "BextBaseBootstrapperExtension.h"
5
6 class CWixUtilBootstrapperExtension : public CBextBaseBootstrapperExtension
7 {
8 public: // IBootstrapperExtension
9 virtual STDMETHODIMP Search(
10 __in LPCWSTR wzId,
11 __in LPCWSTR wzVariable
12 )
13 {
14 HRESULT hr = S_OK;
15
16 hr = UtilSearchExecute(&m_searches, wzId, wzVariable, m_pEngine);
17
18 return hr;
19 }
20
21 public: //CBextBaseBootstrapperExtension
22 virtual STDMETHODIMP Initialize(
23 __in const BOOTSTRAPPER_EXTENSION_CREATE_ARGS* pCreateArgs
24 )
25 {
26 HRESULT hr = S_OK;
27 IXMLDOMDocument* pixdManifest = NULL;
28 IXMLDOMNode* pixnBootstrapperExtension = NULL;
29
30 hr = __super::Initialize(pCreateArgs);
31 BextExitOnFailure(hr, "CBextBaseBootstrapperExtension initialization failed.");
32
33 hr = XmlLoadDocumentFromFile(m_sczBootstrapperExtensionDataPath, &pixdManifest);
34 BextExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBootstrapperExtensionDataPath);
35
36 hr = BextGetBootstrapperExtensionDataNode(pixdManifest, UTIL_BOOTSTRAPPER_EXTENSION_ID, &pixnBootstrapperExtension);
37 BextExitOnFailure(hr, "Failed to get BootstrapperExtension '%ls'", UTIL_BOOTSTRAPPER_EXTENSION_ID);
38
39 hr = UtilSearchParseFromXml(&m_searches, pixnBootstrapperExtension);
40 BextExitOnFailure(hr, "Failed to parse searches from bundle extension manifest.");
41
42 LExit:
43 ReleaseObject(pixnBootstrapperExtension);
44 ReleaseObject(pixdManifest);
45
46 return hr;
47 }
48
49 public:
50 CWixUtilBootstrapperExtension(
51 __in IBootstrapperExtensionEngine* pEngine
52 ) : CBextBaseBootstrapperExtension(pEngine)
53 {
54 m_searches = { };
55 }
56
57 ~CWixUtilBootstrapperExtension()
58 {
59 UtilSearchUninitialize(&m_searches);
60 }
61
62 private:
63 UTIL_SEARCHES m_searches;
64 };
65
66 HRESULT UtilBootstrapperExtensionCreate(
67 __in IBootstrapperExtensionEngine* pEngine,
68 __in const BOOTSTRAPPER_EXTENSION_CREATE_ARGS* pArgs,
69 __out IBootstrapperExtension** ppBootstrapperExtension
70 )
71 {
72 HRESULT hr = S_OK;
73 CWixUtilBootstrapperExtension* pExtension = NULL;
74
75 pExtension = new CWixUtilBootstrapperExtension(pEngine);
76 BextExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CWixUtilBootstrapperExtension.");
77
78 hr = pExtension->Initialize(pArgs);
79 BextExitOnFailure(hr, "CWixUtilBootstrapperExtension initialization failed.");
80
81 *ppBootstrapperExtension = pExtension;
82 pExtension = NULL;
83
84 LExit:
85 ReleaseObject(pExtension);
86 return hr;
87 }