The question is longer than usual, but I tried to clarify. Please carry me and read the whole question, this can be an interesting problem.
I have method A, which currently accepts an object with two List<X> properties, but represents two different objects and therefore the property is aptly named R and S. Class structure
class A { List<X> R; List<X> S; }
and now I have a method that accepts type A input and works with both (assembly and signatures below)
public void updateMe(A objA) { }
now I have a case where I need to reuse this method, but now the fact is that I do not need to distinguish between entities and, therefore, have one list, List<X> T.
Now my question is how to reorganize the method for working with one list, but at the same time provide the ability to distinguish between two lists in the previous case.
My method will update these collections, thus either add to or remove from the list.
My solution now is to create new classes to represent two different entities that are derived from X, and then pass this list of the base class to my method and let the method update this base class, and then, reading it, I can determine which object is type.
So my new classes will be
public class X1:X { } public class X2:X { } class A { List<X> R; }
Is this the best solution or are there any other approaches that I could use here. I just don't like the idea of ββextending a class just to identify the type without adding any properties.