Joel
Joel

Reputation: 1630

Library MAY need to reference the application using it? C#

Sorry for dodgy title, couldn't think of anything better...

Anyway, I have written a library for the viewing of a system basically. This library is used by the editor application of the system. Unfortunately, i got hit by the sudden need for the library to have a variable in one of its classes to access the editing application. Of course this isn't possible without a reference. The thing is, i feel it is unnecessary to reference the editor application when out of the hundreds of times this library may be used, only one of the applications using it (the editor), will mean the library needs to have the editor referenced to it.

I really hope that made sense.

In most cases : Application uses Library In editor case: Editor uses Library uses Editor

I basically want a way around having to reference the editor from the library. All my requirements is for a variable of type (or a loop hole to access) MyClass (default value null) to be stored in the library. MyClass is part of the editor though, not the library, and i DO NOT want to have to reference the editor.

Thanks for any help!

Upvotes: 0

Views: 53

Answers (1)

usr
usr

Reputation: 171178

Create an interface which you "Editor" implements. The library does not need to know the concrete implementation, it can work with the interface.

Upvotes: 5

Related Questions