summaryrefslogtreecommitdiff
path: root/unsorted/efl_mono/EoInherit01.cs
blob: 42a24d5b633c637d6f067ebae567aee63eab33ea (plain) (blame)
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
using static System.Console;

class PlusTenNumberWrapper : example.NumberwrapperInherit
{
    public PlusTenNumberWrapper(Efl.Object parent = null)
        : base(parent)
    {}

    public bool derivedCalled = false;

    override public void SetNumber(int n)
    {
        // Call native EFL method
        base.SetNumber(n + 10);
        derivedCalled = true;
    }
}

public class ExampleEoInherit01
{
    public static void Main()
    {
        Eina.Config.Init();
        Efl.eo.Config.Init();

        var inheritObj = new PlusTenNumberWrapper();

        WriteLine("## Using inherit object ##\n");

        int given = 111;

        // Call the C# override from the C method
        inheritObj.CallNumberSet(given);

        WriteLine($"Override successfully called? {inheritObj.derivedCalled}!\n");

        // Call C function from C# object
        int stored = inheritObj.GetNumber();

        WriteLine($"Given value: {given}");
        WriteLine($"Stored value: {stored}\n");

        // Call C# override directly
        given = 333;
        inheritObj.SetNumber(given);

        stored = inheritObj.GetNumber();

        WriteLine($"Given value: {given}");
        WriteLine($"Stored value: {stored}\n");

        WriteLine("## Using original object ##\n");

        // Check original EFL object
        var origObj = new example.Numberwrapper();
        given = 111;
        origObj.SetNumber(given);
        stored = origObj.GetNumber();

        WriteLine($"Given value: {given}");
        WriteLine($"Stored value: {stored}\n");
    }
}