.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[assembly: CommandClass(typeof(AutoCAD_CSharp_plug_in1.MyCommands))]

3 REPLIES 3
Reply
Message 1 of 4
Selevkos
1722 Views, 3 Replies

[assembly: CommandClass(typeof(AutoCAD_CSharp_plug_in1.MyCommands))]

Hello,

 

Can anyone explain the code line below:

 

[assembly: CommandClass(typeof(AutoCAD_CSharp_plug_in1.MyCommands))]

 

In the autocad plugin for visual studio it is written " This line is not mandatory, but improves loading performances"

 

I realized that, the commandmethod written in different class is not working if this line is used previous to a class.

 

???

3 REPLIES 3
Message 2 of 4
jeff
in reply to: Selevkos

It is a custom attribute, and notice the assembly: at the begining.

 

So this attribute is applies to the assembly. So instead of searching metadata in all the types in your assembly using this attribute allows the ExtensionLoader just to check at the assembly level which types contain methods to be used as commands.

 

Say your were assigned the task to get a list of all the rooms in a hotel with a king size bed and blue sheets for 3 hotels.

 

  • The first hotel gives you master key and you have to go in every room and check.

 

  • The second hotel gives a master key and tells you Room 100 has King size bed, but other rooms might have a king size bed also. You still have to check every room

 

  • The third hotel tells you here is a list of every room with a king size bed. So now you would just have to check these rooms for the color of sheets. 

 

So there would be no point in the attruibute unless it can skip searching types that do not contain CommandMethods. 

 

So if tell it one type contains commandmethods then you need to tell it all the types that contain commandmethods

 

So just add the attribute for each type(Class) that contains CommandMethods, you can them class file or in file, etc...

 

See link for more information

http://spiderinnet1.typepad.com/blog/2012/07/commandclass-and-some-clarifications.html

You can also find your answers @ TheSwamp
Message 3 of 4
Selevkos
in reply to: jeff

Thank you for the reply.

It is now clarified to me: I must use it 🙂

Message 4 of 4
jeff
in reply to: Selevkos

You do not have to use it, but if you do you must add one for each class that contains CommandMethods.

 

If your project does not have any CommandClass attributes then the ExtensionLoader will search every class, and will find them if defined in different classes.

You can also find your answers @ TheSwamp

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost