-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IComponentConnector2 doesn't exist in WinUI (#1156)
* IComponentConnector2 doesn't exist in WinUI * added new header
- Loading branch information
Showing
5 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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, 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, 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{}; | ||
}; | ||
} |