Importing Custom namespace

Importing Custom namespace

kerry_w_brown
Advisor Advisor
410 Views
4 Replies
Message 1 of 5

Importing Custom namespace

kerry_w_brown
Advisor
Advisor

I'd like to know the logic AutoCAD used to handle loading Custom Assemblies from a namespace using directive.

Are all types defined in a namespace imported ?
. . . .  or only the types required by that particular assembly ?

Does 'AutoCAD' check if a namespace has been previously loaded, and only load if not previously loaded. ?

 

If so, can we assume that several custom assemblies can/do use the same loaded 'namespace' for the types they have in common. ??


Regards,
Kerry

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
411 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi Kerry,

This is not specific to AutoCAD, this is the way Visual Studio works.

From Microsoft documentation:

" the using directive imports all the types from a single namespace"

except with the 'static' modifier:

"The static modifier imports the static members and nested types from a single type rather than importing all the types in a namespace."

I do not think the word "load" is appropriated for namespaces. Namespaces are related to the type names, not their implementation.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

_gile
Consultant
Consultant

@kerry_w_brown  a écrit :

can we assume that several custom assemblies can/do use the same loaded 'namespace' for the types they have in common. ??


I'm not sure to fully understand.

If several assemblies can use the same namespace (Autodesk.AutoCAD.Runtime is used by the accoremgd, acdbmgd and acmgd assemblies), there can't be the same type name for different types in different assemblies.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 5

kerry_w_brown
Advisor
Advisor

Hi Gilles,

I expressed that badly.
I want to be sure that several assemblies will be able to share stand alone libraries.

 

 

 

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 5 of 5

daniel_cadext
Advisor
Advisor

Not sure if this helps, but

 

Reflect on Autodesk.AutoCAD.Runtime.ExtensionLoader, OnAssemblyResolve, OnAssemblyLoad, ProcessAssembly

There’s a hashmap of loaded assemblies (and their references) and of classes that have been declared with one of AutoCAD’s custom attributes.

Guessing that AutoCAD knows what assemblies have been loaded, directly, or by reference, and if a type is loaded that has an attribute.

 

Everything else is probably done by the framework.

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes