From: Martin C. <mar...@ei...> - 2004-09-30 20:53:37
|
Francois, I have gotten the UDC to work as follows: Assembly[] arOfAssemblies = AppDomain.CurrentDomain.GetAssemblies(); ObjectHandle obj = null; foreach( Assembly _asm in arOfAssemblies ) { if( _asm.FullName.Substring( 0, 14 ) == "WorkflowShapes" ) { Type[] arOfTypes = _asm.GetTypes(); foreach( Type _type in arOfTypes ) { if( _type.Name == "Rule" ) { obj = AppDomain.CurrentDomain.CreateInstance (_asm.FullName, _type.FullName ); break; } } } } connection = (Connection)obj.Unwrap(); I need to refactor it to remove the hard coding and to use properties, but this code loads the Connection class by name. Now considering the fact that the shape libraries can be loaded at runtime, I'm thinking this code should execute after any call to LoadLibraries(). What do you think? BTW: I'm going to have a go at GraphML support over the next few days. Are you available to bounce ideas off? :-) Regards, Martin I have no time before tomorrow to look closer at the code you wrote but I can tell you the kind of problem I often encountered in the past. Assume you have two identical classes, one inside your main application and one put in a separate assembly. Next you reflect the latter one in your main application...it's *not* the same class as the one in your main application because the CLR takes also the signature of the assembly it belongs to. For example, on trying things like If typeof(myReflectedInstance)==Blabla.MyClass ... This will return false! The way out it using interfaces, if you assign a reflected class to an interface it will work. Netron uses this a lot, have a look at the graph lib reflection or the way NAF imports plugins. The disadvantage of this is that everything you want to use in your main app needs to be defined (via interfaces). Well, not really a problem, seems a good thing to have things under control when reflecting. I believe the divergence between classes and reflected identical classes is related to the way .Net is imposing security. There is a lot of stuff going on behind the screen with respect to security, even if one doesn't use it. Hope this helps you, if you cannot find a way out I'll look at it in the weekend. By the way, if you use Messenger you can reach me at 'NetronProject(@)hotmail.com'. See you! ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ Netron-graphlib mailing list Net...@li... https://lists.sourceforge.net/lists/listinfo/netron-graphlib |