-
Notifications
You must be signed in to change notification settings - Fork 247
/
base_xaml_component_connector_winui.h
52 lines (46 loc) · 1.54 KB
/
base_xaml_component_connector_winui.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
WINRT_EXPORT namespace winrt::Microsoft::UI::Xaml::Markup
{
template <typename D>
struct ComponentConnectorT : D
{
using composable_base = typename D::composable_base;
void InitializeComponent()
{
if constexpr (m_has_connectable_base)
{
m_dispatch_base = true;
composable_base::InitializeComponent();
m_dispatch_base = false;
}
D::InitializeComponent();
}
void Connect(int32_t connectionId, winrt::Windows::Foundation::IInspectable const& target)
{
if constexpr (m_has_connectable_base)
{
if (m_dispatch_base)
{
composable_base::Connect(connectionId, target);
return;
}
}
D::Connect(connectionId, target);
}
auto GetBindingConnector(int32_t connectionId, winrt::Windows::Foundation::IInspectable const& target)
{
if constexpr (m_has_connectable_base)
{
if (m_dispatch_base)
{
return composable_base::GetBindingConnector(connectionId, target);
}
}
return D::GetBindingConnector(connectionId, target);
}
private:
static constexpr bool m_has_connectable_base{
impl::has_initializer<composable_base>::value &&
impl::has_interface<D, IComponentConnector>() };
bool m_dispatch_base{};
};
}