.NET

Reply
Active Member
Selevkos
Posts: 9
Registered: ‎04-05-2013
Message 1 of 4 (294 Views)

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

294 Views, 3 Replies
06-12-2013 11:02 AM

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.

 

???

Valued Mentor
jeff
Posts: 331
Registered: ‎05-12-2009
Message 2 of 4 (277 Views)

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

06-12-2013 03:49 PM 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
Active Member
Selevkos
Posts: 9
Registered: ‎04-05-2013
Message 3 of 4 (239 Views)

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

06-13-2013 11:05 AM in reply to: jeff

Thank you for the reply.

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

Valued Mentor
jeff
Posts: 331
Registered: ‎05-12-2009
Message 4 of 4 (231 Views)

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

06-13-2013 03:37 PM 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.