blob: c8d29f8b835490aec7e3e6714ca17d530c6e8399 (
plain)
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
|
/*
* Eina.Iterator examples.
*
* These examples demonstrate how to work with Eina.Iterator methods.
* Both an Eina.List and an Eina.Array are created and an iterator obtained
* for both. You can see how we can use iterators irrespective of the source
* and also that there are different ways to work with iterating content.
*/
using System;
public class Example : Efl.Csharp.Application
{
static void PrintIterator(Eina.Iterator<string> it)
{
Console.WriteLine("--iterator start--");
foreach(string s in it)
Console.WriteLine(s);
Console.WriteLine("-- iterator end --");
}
static Eina.Array<string> CreateArray()
{
string[] strings =
{
"name strings",
"husker",
"starbuck",
"boomer"
};
var array = new Eina.Array<string>(4u);
foreach (string s in strings)
array.Push(s);
return array;
}
static Eina.List<string> CreateList()
{
string[] more_strings = {
"sentence strings",
"what do your hear?",
"nothing but the rain",
"then grab your gun and bring the cat in"
};
var list = new Eina.List<string>();
foreach (string s in more_strings)
list.Append(s);
return list;
}
protected override void OnInitialize(string[] args)
{
// Create an Eina.Array and iterate through its contents
var array = CreateArray();
var it = array.GetIterator();
PrintIterator(it);
it.Dispose();
array.Dispose();
// Perform the same iteration with an Eina.List
var list = CreateList();
it = list.GetIterator();
PrintIterator(it);
it.Dispose();
list.Dispose();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}
|