hostfxroptions.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the MIT License. See License.txt in the project root for license information.
  3. #pragma once
  4. #include <Windows.h>
  5. #include <memory>
  6. #include <filesystem>
  7. #include <utility>
  8. #include <vector>
  9. #include <string>
  10. class HOSTFXR_OPTIONS
  11. {
  12. public:
  13. HOSTFXR_OPTIONS(
  14. std::filesystem::path dotnetExeLocation,
  15. std::filesystem::path hostFxrLocation,
  16. std::vector<std::wstring> arguments
  17. ) noexcept
  18. : m_dotnetExeLocation(std::move(dotnetExeLocation)),
  19. m_hostFxrLocation(std::move(hostFxrLocation)),
  20. m_arguments(std::move(arguments))
  21. {}
  22. void
  23. GetArguments(DWORD &hostfxrArgc, std::unique_ptr<PCWSTR[]> &hostfxrArgv) const
  24. {
  25. hostfxrArgc = static_cast<DWORD>(m_arguments.size());
  26. hostfxrArgv = std::make_unique<PCWSTR[]>(hostfxrArgc);
  27. for (DWORD i = 0; i < hostfxrArgc; ++i)
  28. {
  29. hostfxrArgv[i] = m_arguments[i].c_str();
  30. }
  31. }
  32. const std::filesystem::path&
  33. GetHostFxrLocation() const noexcept
  34. {
  35. return m_hostFxrLocation;
  36. }
  37. const std::filesystem::path&
  38. GetDotnetExeLocation() const noexcept
  39. {
  40. return m_dotnetExeLocation;
  41. }
  42. static
  43. HRESULT Create(
  44. _In_ const std::wstring& pcwzExeLocation,
  45. _In_ const std::wstring& pcwzProcessPath,
  46. _In_ const std::wstring& pcwzApplicationPhysicalPath,
  47. _In_ const std::wstring& pcwzArguments,
  48. _Out_ std::unique_ptr<HOSTFXR_OPTIONS>& ppWrapper);
  49. private:
  50. const std::filesystem::path m_dotnetExeLocation;
  51. const std::filesystem::path m_hostFxrLocation;
  52. const std::vector<std::wstring> m_arguments;
  53. };