forked from microsoft/CsWinRT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSingleton.cpp
43 lines (39 loc) · 1.2 KB
/
Singleton.cpp
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
#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();
}
}