locked
Design - reflection question RRS feed

  • Question

  • User1514925754 posted

    Scenario: There will three seperate solutions projects, projecta and projectp calls projectunique for processing.

    From projecta sends List<employee> and projectb sends List<worker> to projectunique.

    I want to define a method in projectunique which should be smartenough to proess the data based on the caller. i.e I want to define a method which does NOT reference (or contain) employee or worker class as a parameter. I want a generic parameter which handles both. 

    Can we do something with reflection? I may not be clear with my explanation, hope somebody gets it.. :)

    Wednesday, March 27, 2013 9:28 PM

Answers

  • User1859182686 posted
    You would create a circular reference here. The unique method would need to 'know' about a and b in order to identify them. Project a and b would need to know about unique in order to call it. Without knowing more I would be thinking the employee/worker objects should be either from an interface or common base class that exposes a delegate. You can hand off the unique processing to a method in the project, I.e. project a has a do something method you attach to employee via a delegate, the unique project can then call it from within its implementation. This is still circular so that base class probably needs pulling out to a common model library. Either way, you've got some peculiarities with this architecture that perhaps need a rethink or more explanation.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 28, 2013 3:03 AM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 31, 2013 8:27 PM

All replies

  • User1859182686 posted
    You would create a circular reference here. The unique method would need to 'know' about a and b in order to identify them. Project a and b would need to know about unique in order to call it. Without knowing more I would be thinking the employee/worker objects should be either from an interface or common base class that exposes a delegate. You can hand off the unique processing to a method in the project, I.e. project a has a do something method you attach to employee via a delegate, the unique project can then call it from within its implementation. This is still circular so that base class probably needs pulling out to a common model library. Either way, you've got some peculiarities with this architecture that perhaps need a rethink or more explanation.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 28, 2013 3:03 AM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 31, 2013 8:27 PM
  • User-1716951449 posted

    you don't need reflection.

    you can look into using interface, or the generic.

    interface should be good enough, and more easy to be maintain.

    generic seems quite interesting, but there are lot of restriction/limitation over general oop.

    Tuesday, April 2, 2013 5:39 AM