-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added caching of event registration state to support unsubscribes acr…
…oss garbage collections (#861) * added caching of event registration state to support unsubscribes across GCs * PR feedback and add missing files * treat compile warnings as errors * remove warnings
- Loading branch information
Showing
13 changed files
with
327 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "pch.h" | ||
#include "Singleton.h" | ||
#include "Singleton.g.cpp" | ||
|
||
using namespace winrt; | ||
using namespace Windows::Foundation; | ||
|
||
namespace winrt::TestComponentCSharp::implementation | ||
{ | ||
TestComponentCSharp::ISingleton Singleton::Instance() | ||
{ | ||
struct singleton : winrt::implements<singleton, ISingleton> | ||
{ | ||
int _int{}; | ||
winrt::event<EventHandler<int32_t>> _intChanged {}; | ||
|
||
int32_t IntProperty() | ||
{ | ||
return _int; | ||
} | ||
void IntProperty(int32_t value) | ||
{ | ||
_int = value; | ||
_intChanged(nullptr, _int); | ||
} | ||
winrt::event_token IntPropertyChanged(EventHandler<int32_t> const& handler) | ||
{ | ||
return _intChanged.add(handler); | ||
} | ||
void IntPropertyChanged(winrt::event_token const& token) noexcept | ||
{ | ||
_intChanged.remove(token); | ||
} | ||
}; | ||
static TestComponentCSharp::ISingleton _singleton = winrt::make<singleton>(); | ||
return _singleton; | ||
} | ||
|
||
void Singleton::Instance(TestComponentCSharp::ISingleton const& value) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
} |
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,19 @@ | ||
#pragma once | ||
#include "Singleton.g.h" | ||
|
||
namespace winrt::TestComponentCSharp::implementation | ||
{ | ||
struct Singleton | ||
{ | ||
Singleton() = default; | ||
|
||
static TestComponentCSharp::ISingleton Instance(); | ||
static void Instance(TestComponentCSharp::ISingleton const& value); | ||
}; | ||
} | ||
namespace winrt::TestComponentCSharp::factory_implementation | ||
{ | ||
struct Singleton : SingletonT<Singleton, implementation::Singleton> | ||
{ | ||
}; | ||
} |
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
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
Oops, something went wrong.