-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
CodePushConfig.h
66 lines (49 loc) · 2.6 KB
/
CodePushConfig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "CodePushConfig.g.h"
#include "NativeModules.h"
#include <string_view>
#include "winrt/Microsoft.ReactNative.h"
#include "winrt/Windows.Data.Json.h"
#include "winrt/Windows.Foundation.Collections.h"
namespace winrt::Microsoft::CodePush::ReactNative::implementation
{
struct CodePushConfig : CodePushConfigT<CodePushConfig>
{
CodePushConfig() = default;
static void Init(Windows::Foundation::Collections::IMap<hstring, hstring> const& configMap) noexcept;
static void SetHost(Microsoft::ReactNative::ReactNativeHost const& host) noexcept;
static CodePushConfig& Current() noexcept;
hstring GetAppVersion() { return QueryConfig(AppVersionConfigKey); }
void SetAppVersion(std::wstring_view appVersion) { m_configuration.Insert(AppVersionConfigKey, appVersion); }
hstring GetBuildVersion() { return QueryConfig(BuildVersionConfigKey); }
Windows::Data::Json::JsonObject GetConfiguration();
hstring GetDeploymentKey() { return QueryConfig(DeploymentKeyConfigKey); }
void SetDeploymentKey(std::wstring_view deploymentKey) { m_configuration.Insert(DeploymentKeyConfigKey, deploymentKey); }
hstring GetServerUrl() { return QueryConfig(ServerURLConfigKey); }
void SetServerUrl(std::wstring_view serverUrl) { m_configuration.Insert(ServerURLConfigKey, serverUrl); }
hstring GetPublicKey() { return QueryConfig(PublicKeyKey); }
void SetPublicKey(std::wstring_view publicKey) { m_configuration.Insert(PublicKeyKey, publicKey); }
private:
static constexpr std::wstring_view AppVersionConfigKey{ L"appVersion" };
static constexpr std::wstring_view BuildVersionConfigKey{ L"buildVersion" };
static constexpr std::wstring_view ClientUniqueIDConfigKey{ L"clientUniqueId" };
static constexpr std::wstring_view DeploymentKeyConfigKey{ L"deploymentKey" };
static constexpr std::wstring_view ServerURLConfigKey{ L"serverUrl" };
static constexpr std::wstring_view PublicKeyKey{ L"publicKey" };
Windows::Foundation::Collections::IMap<hstring, hstring> m_configuration;
static CodePushConfig s_currentConfig;
hstring QueryConfig(std::wstring_view key);
};
}
namespace winrt::Microsoft::CodePush::ReactNative::factory_implementation
{
struct CodePushConfig : CodePushConfigT<CodePushConfig, implementation::CodePushConfig>
{
};
}
namespace Microsoft::CodePush::ReactNative
{
using winrt::Microsoft::CodePush::ReactNative::implementation::CodePushConfig;
}