Parent reference (cross link) problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sidorf

    Parent reference (cross link) problem

    Hi

    It's a little hard for me to explain my problem, but i'll try. I have
    an application in which i have a ManagerClass, many ClientClass-es ans
    some ControlClass.
    The ManagerClass creates one or more instances of ClientClass.
    ClientClass creates some controls from ControlClass.
    In the ControlClass i have derived some common control classes and
    added some functionalities .

    Here comes the problem:
    when one Event handler from COntrolClass is fired , i need it to be
    treated by the ManagerClass , depending on the state of the ClientClass
    and the ControlClass that generated that event.

    My approach , so far is working , but i'm sure it's not the best way to
    do it , as i'm having lots of cross references:
    the ClientClass is in a dll file, and i have it as a reference in
    ManagerClass, so i can create instances of ClientClass from the
    manager.
    In ClientClass, in order to call a Method from the ManagerClass, i have
    a reference to the ManagerClass, passed to the ClientClass Constructor.

    THe same problem is with ControlClass and client class, same mechanism
    used. is there any other way that i can do this?
    thx

  • Ollie Riches

    #2
    Re: Parent reference (cross link) problem

    Sidorf,

    Correct me if I am wrong but it sounds as thought you have a parent child
    relationship between your ManagerClass and the ClientClass and a parent
    grandchild relationship between your ManagerClass and your ControlClass that
    is contained in the ClientClass.

    Your goal is to have notifications from ClientClass to your ManagerClass and
    notifications from your ControlClass to the ManagerClass. So you want to
    'bubble' events of importance from classes contained within other classes.

    You should check using 'events' and 'delegates' in the .Net framework -
    these are mechanism that allow you fire notifications to interested parties.
    So you could setup an event on your ClientClass that is monitored by your
    ManagerClass and you could also set up an event on your ClientClass that
    fires when a ControlClass is added to the ClientClass have this monitored by
    the ManagerClass and hence you can then setup another monitor for events on
    the ControlClass - hope that isn't to confusing!

    The approach described above does not require any of the children in the
    parent child relationships to have an explicit reference to the parent.

    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.




    Check the links below:


    HTH

    Ollie Riches


    "Sidorf" <ciprian.tarcea @gmail.com> wrote in message
    news:1126607195 .568131.107530@ z14g2000cwz.goo glegroups.com.. .[color=blue]
    > Hi
    >
    > It's a little hard for me to explain my problem, but i'll try. I have
    > an application in which i have a ManagerClass, many ClientClass-es ans
    > some ControlClass.
    > The ManagerClass creates one or more instances of ClientClass.
    > ClientClass creates some controls from ControlClass.
    > In the ControlClass i have derived some common control classes and
    > added some functionalities .
    >
    > Here comes the problem:
    > when one Event handler from COntrolClass is fired , i need it to be
    > treated by the ManagerClass , depending on the state of the ClientClass
    > and the ControlClass that generated that event.
    >
    > My approach , so far is working , but i'm sure it's not the best way to
    > do it , as i'm having lots of cross references:
    > the ClientClass is in a dll file, and i have it as a reference in
    > ManagerClass, so i can create instances of ClientClass from the
    > manager.
    > In ClientClass, in order to call a Method from the ManagerClass, i have
    > a reference to the ManagerClass, passed to the ClientClass Constructor.
    >
    > THe same problem is with ControlClass and client class, same mechanism
    > used. is there any other way that i can do this?
    > thx
    >[/color]


    Comment

    • Sidorf

      #3
      Re: Parent reference (cross link) problem

      Hi Ollie
      thanks for your quick reply. Seems like a solution to my problem. i'll
      do some reading now and i'll post any further quiestions on delegates
      issue.
      Thanks again

      Comment

      Working...