[Vala] Implicating two interface, when methods name are different(name conflict)




I has some C#/.Net past and it possible to implicate two different interface, where both contains "foo" 
method.
The idea behinds this solution, is that one of the implication must be explicit:
public interface ISampleInterface1
{
    void Foo();
}

public interface ISampleInterface2
{
    void Foo();
}


class ImplementationClass : ISampleInterface
{
    // Explicit interface member implementation: 
    void ISampleInterface1.Foo()
    {
        // Method implementation.
    }

    // Explicit interface member implementation: 
    void ISampleInterface2.Foo()
    {
        // Method implementation.
    }

    // Not an interface member implementation: 
    public void Foo()
    {
        // Method implementation.
    }

    static void Main()
    {
        // Declare an class instance.
        ImplementationClass obj = new ImplementationClass();
        // Call the member of class.
        obj.SampleMethod();

        ISampleInterface1 obj1 = obj;
        // Call the member of ISampleInterface1
        obj1.SampleMethod();

        
        ISampleInterface2 obj2 = obj;
        // Call the member of ISampleInterface1
        obj2.SampleMethod();
    }
}

This code is based on MSDN(with modifications).
I don't know weather it's possible to do this in GObject and Vala, and how to if possible?
Does this approach and model is wrong?(Because I know Vala interface are more powerful than most langs)

Yours,
Tal
                                          


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]