-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCollectionTester.cpp
64 lines (54 loc) · 2.19 KB
/
CollectionTester.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "pch.h"
#include "CollectionTester.h"
#include "CollectionTester.g.cpp"
namespace winrt::test_component::implementation
{
hstring CollectionTester::InIterable(Windows::Foundation::Collections::IIterable<hstring> const& value)
{
return value.First().Current();
}
hstring CollectionTester::InIterablePair(Windows::Foundation::Collections::IIterable<Windows::Foundation::Collections::IKeyValuePair<hstring, hstring>> const& value)
{
return value.First().Current().Key();
}
hstring CollectionTester::InMap(Windows::Foundation::Collections::IMap<hstring, hstring> const& value)
{
return value.Lookup(L"A");
}
hstring CollectionTester::InMapView(Windows::Foundation::Collections::IMapView<hstring, hstring> const& value)
{
return value.Lookup(L"A");
}
hstring CollectionTester::InVector(Windows::Foundation::Collections::IVector<hstring> const& value)
{
if (value.Size() == 0) return L"empty";
return value.GetAt(0);
}
hstring CollectionTester::InVectorView(Windows::Foundation::Collections::IVectorView<hstring> const& value)
{
return value.GetAt(0);
}
void CollectionTester::GetObjectAt(winrt::Windows::Foundation::Collections::IVector<winrt::Windows::Foundation::IInspectable> const& value, uint32_t index, winrt::test_component::ObjectHandler const& callback)
{
auto item = value.GetAt(index);
callback(item);
}
winrt::Windows::Foundation::Collections::IIterable<hstring> CollectionTester::VectorAsIterable(winrt::Windows::Foundation::Collections::IVector<hstring> const& value)
{
return value.as<Windows::Foundation::Collections::IIterable<hstring>>();
}
Windows::Foundation::Collections::IVector<hstring> CollectionTester::ReturnStoredStringVector()
{
if (m_vector.Size() == 0)
{
m_vector.Append(L"Hello");
}
return m_vector;
}
Windows::Foundation::Collections::IMap<hstring, hstring> CollectionTester::ReturnMapFromStringToString()
{
auto map = winrt::single_threaded_map<hstring, hstring>();
map.Insert(L"A", L"Alpha");
return map;
}
}