Passing objects between classes

Add-in Express™ Support Service
That's what is more important than anything else

Passing objects between classes
 
Tonio Rolle




Posts: 16
Joined: 2006-12-14
Hi,

I just installed and started working with ADX VSTO. Thanks for a terrific product.

Question: I have a Hashtable class, Map.cs. I instantiate and populate this hastable in ThisDocument.cs. I now need to get access to and process the information stored in the populated hashtable variables in ADXModule1.cs. When the user clicks the button, code must process the information stored in the Hashtable in ThisDocument.cs. I know this is really basic but I can't figure it out.

Thanks in advance for any help.
Posted 14 Dec, 2006 23:47:26 Top
Matthias Kwiedor




Posts: 35
Joined: 2004-10-14
Just create a handle from ADXModule1 to ThisDocument Class, which i think allready is avaible. Than create a new handle to call from ADXModule1, to start the process and give back the created hashtable or create a global hashtable in the ThisDocument Class and create a public variable where you can access from the ADXModule1.

I don't know if you call a method from ADXModule while pressing a button or a timer/thread calls a method in ThisDocument Class. If it will be called with timer/thread, you can just simple create a Event Handler in the ThisDocument Class which calls a method in ADXModule.

Public Properties: http://www.c-sharpcorner.com/Language/PropertiesInCSRVS.asp
Event Handler: http://www.developerfusion.co.uk/show/2137/3/
Posted 15 Dec, 2006 04:41:23 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Tonio.

You can also cast this.ThisApplication property of the ADXModule1 class to the ThisDocument class. Then you can access the VSTO application directly from the adxmodule.

e.g ThisDocument vstoDoc = (this.ThisApplication as ThisDocument);
Posted 15 Dec, 2006 13:56:51 Top
Tonio Rolle




Posts: 16
Joined: 2006-12-14
thanks everyone for the help. I read the article "Understanding C# Properties" and I still have a (beginner) question:

in class MyClient, we have "MyClass mc = new MyClass();
mc.SetX(10);"

what if we have class MyClient2 -- how would I get access to the value of mc.SetX(10) which was performed in class MyClient?
Posted 15 Dec, 2006 19:11:47 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Tonio.

You just need to create a new public property in the MyClient class and access the value via the property.
Posted 18 Dec, 2006 08:31:50 Top