0

I would like to know if the following is possible:

I have 2 resource managers A and B. Only A have all the strings entries and B only have some alternative values for some of the entries in A.

ex:

A.foo
A.bar
B.bar

I would like to be able to do something like B.foo were foo doesn't exist in B but exists in A so it would return A.foo. But if B.bar exists I want it to return B.bar and not A.bar.

Is this possible? (I want to get the entries without string selectors to ensure code correctness during compile time)

RicardoSBA
  • 785
  • 1
  • 6
  • 18

1 Answers1

0

I am not sure if there is any hierarchy in your classes (A & B), but if there is this seems like a good use-case for virtual methods.

For example:

public class A
{
    public virtual string foo()
    {
        return "A Foo";
    }

    public string bar()
    {
        return "A Bar";
    }
}

public class B:A
{
    public override string foo()
    {
        return "B Foo";
    }
}

Class B inherits Class A. By marking the method in class A as virtual, you can override the method in Class B. If class B does not implement method Bar(), Class A's Bar() method will be invoked.

Is this what you wanted?

Shai Cohen
  • 6,074
  • 4
  • 31
  • 54