Home All Groups Group Topic Archive Search About

strong reference between objects in different assemblies

Author
1 May 2006 6:37 PM
Craig Buchanan
i have two classes: User and Group.  Each is in their own assembly.  The
User class has  Groups collection and the Group has a Users collection.  I
would like to strongly-type these collections, but i can't seem to avoid the
circular reference between projects.  is there a way around this?

Thanks,

Craig Buchanan

Author
1 May 2006 8:45 PM
Göran_Andersson
You could use an interface.

Craig Buchanan wrote:
Show quoteHide quote
> i have two classes: User and Group.  Each is in their own assembly.  The
> User class has  Groups collection and the Group has a Users collection.  I
> would like to strongly-type these collections, but i can't seem to avoid the
> circular reference between projects.  is there a way around this?
>
> Thanks,
>
> Craig Buchanan
>
>
Author
1 May 2006 11:39 PM
Craig Buchanan
an interface that they both share?

currently, they both inherit the same base case (in a third assembly).

Show quoteHide quote
"Göran Andersson" <gu***@guffa.com> wrote in message
news:e%23c%23kAWbGHA.3692@TK2MSFTNGP05.phx.gbl...
> You could use an interface.
>
> Craig Buchanan wrote:
>> i have two classes: User and Group.  Each is in their own assembly.  The
>> User class has  Groups collection and the Group has a Users collection.
>> I would like to strongly-type these collections, but i can't seem to
>> avoid the circular reference between projects.  is there a way around
>> this?
>>
>> Thanks,
>>
>> Craig Buchanan
Author
3 May 2006 4:25 PM
Göran_Andersson
No, you only need an interface for one class. Then the other class can
use the interface for handling objects of the first class, and doesn't
even need to know that the first class exists.

Craig Buchanan wrote:
Show quoteHide quote
> an interface that they both share?
>
> currently, they both inherit the same base case (in a third assembly).
>
> "Göran Andersson" <gu***@guffa.com> wrote in message
> news:e%23c%23kAWbGHA.3692@TK2MSFTNGP05.phx.gbl...
>> You could use an interface.
>>
>> Craig Buchanan wrote:
>>> i have two classes: User and Group.  Each is in their own assembly.  The
>>> User class has  Groups collection and the Group has a Users collection.
>>> I would like to strongly-type these collections, but i can't seem to
>>> avoid the circular reference between projects.  is there a way around
>>> this?
>>>
>>> Thanks,
>>>
>>> Craig Buchanan
>
>
Author
3 May 2006 5:10 PM
Craig Buchanan
If I keep the interface in the same assembly as the class, i haven't solved
the problem.  for example:

MyFramework.Plugins.UserPlugin assembly contains:
User class
IUser interface

MyFramework.Plugins.GroupPlugin assembly contains:
Group class
IGroup interface

The GroupPlugin assembly can have a reference to the UserPlugin or
UserPlugin assembly can have a reference to the GroupPlugin, but not both at
the same time.

My goal is to create a plugin framework, where a given framework can have a
strong reference to a class in another plugin assembly.  i want to have the
option to have interdependencies as well (as above).

I may have to have both of these classes in one assembly.

thoughts?

Show quoteHide quote
"Göran Andersson" <gu***@guffa.com> wrote in message
news:etpc94sbGHA.1856@TK2MSFTNGP03.phx.gbl...
> No, you only need an interface for one class. Then the other class can use
> the interface for handling objects of the first class, and doesn't even
> need to know that the first class exists.
>
> Craig Buchanan wrote:
>> an interface that they both share?
>>
>> currently, they both inherit the same base case (in a third assembly).
>>
>> "Göran Andersson" <gu***@guffa.com> wrote in message
>> news:e%23c%23kAWbGHA.3692@TK2MSFTNGP05.phx.gbl...
>>> You could use an interface.
>>>
>>> Craig Buchanan wrote:
>>>> i have two classes: User and Group.  Each is in their own assembly.
>>>> The User class has  Groups collection and the Group has a Users
>>>> collection. I would like to strongly-type these collections, but i
>>>> can't seem to avoid the circular reference between projects.  is there
>>>> a way around this?
>>>>
>>>> Thanks,
>>>>
>>>> Craig Buchanan
>>
Author
3 May 2006 6:56 PM
Göran_Andersson
Put the interface for the class in the other assembly:

1:
IUser interface
Group class

2:
User class implements IUser

Assembly 2 references assembly 1. The Group class uses IUser to
reference user objects, and the User class can use Group objects.

Or the other way around if you like. Or you can put interfaces for both
classes in one of the assemblies. Or but the interfaces in a separate
assembly.

Craig Buchanan wrote:
Show quoteHide quote
> If I keep the interface in the same assembly as the class, i haven't solved
> the problem.  for example:
>
> MyFramework.Plugins.UserPlugin assembly contains:
> User class
> IUser interface
>
> MyFramework.Plugins.GroupPlugin assembly contains:
> Group class
> IGroup interface
>
> The GroupPlugin assembly can have a reference to the UserPlugin or
> UserPlugin assembly can have a reference to the GroupPlugin, but not both at
> the same time.
>
> My goal is to create a plugin framework, where a given framework can have a
> strong reference to a class in another plugin assembly.  i want to have the
> option to have interdependencies as well (as above).
>
> I may have to have both of these classes in one assembly.
>
> thoughts?
>
> "Göran Andersson" <gu***@guffa.com> wrote in message
> news:etpc94sbGHA.1856@TK2MSFTNGP03.phx.gbl...
>> No, you only need an interface for one class. Then the other class can use
>> the interface for handling objects of the first class, and doesn't even
>> need to know that the first class exists.
>>
>> Craig Buchanan wrote:
>>> an interface that they both share?
>>>
>>> currently, they both inherit the same base case (in a third assembly).
>>>
>>> "Göran Andersson" <gu***@guffa.com> wrote in message
>>> news:e%23c%23kAWbGHA.3692@TK2MSFTNGP05.phx.gbl...
>>>> You could use an interface.
>>>>
>>>> Craig Buchanan wrote:
>>>>> i have two classes: User and Group.  Each is in their own assembly.
>>>>> The User class has  Groups collection and the Group has a Users
>>>>> collection. I would like to strongly-type these collections, but i
>>>>> can't seem to avoid the circular reference between projects.  is there
>>>>> a way around this?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Craig Buchanan
>