Different property value for contracts

I have two interfaces implemented by one main class. How can i refactor my code in a way that on implementing each contract, the methods of each contract has a different value for a parameter such as DatabaseName.

Example :

  1. Class1 Implements Interface1,Interface2
  2. Interface1.GetData() has DatabaseName set to Database 1
  3. Interface2.GetData() has DatabaseName set to Database 2

I can configure those value in the methods GetData() but i want a cleaner way of doing it.

Any pattern recommendation be that DI ,Domain driven ,even basic inheritance example which accomplishes the above is what i am looking for.

Jon Skeet
people
quotationmark

It sounds like all you need is explicit interface implementation:

public class Class1 : Interface1, Interface2
{
    // Note the lack of access modifier here. That's important!
    Data Interface1.GetData()
    {
        // Implementation for Interface1
    }

    Data Interface2.GetData()
    {
        // Implementation for Interface2
    }
}

Obviously the two methods can call a common method with a parameter to specify the database name or similar.

people

See more on this question at Stackoverflow