- Notifications
You must be signed in to change notification settings - Fork 961
/
Copy pathclass1.h
125 lines (98 loc) · 3.16 KB
/
class1.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#pragma once
#include<collection.h>
namespaceOther
{
}
namespaceDelegatesEvents
{
ref classContactInfo;
// <snippet111>
public delegate Platform::String^ CustomStringDelegate(ContactInfo^ ci);
// </snippet111>
public delegate Platform::String^ CustomGreeting(ContactInfo^ ci);
public delegate voidCustomDelegate(Platform::Object^ sender, Platform::String^ arg);
//<snippet112>
public ref classContactInfo sealed
{
public:
ContactInfo(){}
ContactInfo(Platform::String^ saluation, Platform::String^ last, Platform::String^ first, Platform::String^ address1);
property Platform::String^ Salutation;
property Platform::String^ LastName;
property Platform::String^ FirstName;
property Platform::String^ Address1;
//...other properties
Platform::String^ ToCustomString(CustomStringDelegate^ func)
{
returnfunc(this);
}
};
//</snippet112>
//<snippet116>
generic <typename T>
delegate voidMyEventHandler(T p1, T p2);
//</snippet116>
//<snippet117>
MyEventHandler<float>^ myDelegate;
//</snippet117>
public ref classClass1 sealed
{
public:
Class1();
voidTestDelegate();
static Platform::String^ GetFirstAndLast(ContactInfo^ info);
Platform::String^ GetSalutationAndLast(ContactInfo^ info);
voidConstructDelegate();
Windows::Foundation::Collections::IVector<Platform::String^>^ GetCustomContactStrings(CustomStringDelegate^ del);
property CustomGreeting^ StoredDelegate;
voidTestTemplate();
Platform::String^ CreateGreeting()
{
returnStoredDelegate(m_contacts->GetAt(0));
}
private:
Platform::Collections::Vector<ContactInfo^>^ m_contacts;
CustomGreeting^ _d;
};
public ref classClass2 sealed
{
public:
event CustomDelegate^ OnStringChanged;
voidDoSomethingWithAString(Platform::String^ str)
{
m_str = str + "Test";
OnStringChanged(this, m_str);
}
private:
Platform::String^ m_str;
};
template<typename T, classI>
ref classMyClass
{
public:
MyClass(T s) {}
};
template<> ref classMyClass<Platform::String^, int> sealed
{
public:
MyClass(Platform::String^ s) {}
voidDoSomething(int i){}
};
//<snippet120>
[Windows::Foundation::Metadata::WebHostHiddenAttribute]
ref classApp sealed
{
voidInitializeSensor();
voidSensorReadingEventHandler(Windows::Devices::Sensors::LightSensor^ sender,
Windows::Devices::Sensors::LightSensorReadingChangedEventArgs^ args);
float m_oldReading;
Windows::Devices::Sensors::LightSensor^ m_sensor;
};
//</snippet120>
//<snippet122>
public delegate voidRoutedEventHandler(
Platform::Object^ sender,
Windows::UI::Xaml::RoutedEventArgs^ e
);
//</snippet122>
}