-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for composed implementations of IComponentConnector (#1149)
* add support for composed implementations of IComponentConnector * document ComponentConnectorT helper * revert change for deriving without interfaces - creates other breaks and very atypical scenario * pr feedback * pr feedback * pr feedback * http://slashslash.info/petition/ compliance
- Loading branch information
Showing
7 changed files
with
157 additions
and
29 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
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,53 @@ | ||
|
||
WINRT_EXPORT namespace winrt::%::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>() && | ||
impl::has_interface<D, IComponentConnector2>() }; | ||
|
||
bool m_dispatch_base{}; | ||
}; | ||
} |