ShapeAppBasicCSharpGenericCollectionIndexAdapter Sample


posted by Gary
01-26-2009

Downloads: 565
File size: 729.6kB
Views: 3,072
ShapeAppBasicCSharpGenericCollectionIndexAdapter Sample

Continuing from our previous ShapeAppBasicCSharpGenericCollectionAdapter sample, we will demonstrate how to pass a System.Collections.Generic.IList<ShapeAppCSharp. Document > instance, as a ‘by reference’ parameter, from an AddIn to  ShapeAppBasicCSharp host application.  This is accomplished by extending the VSTA pipeline with generic list adapters and converters that provide Host application with a (cross-AppDomain) reference to a generic collection passed from a VSTA AddIn.  The host application will, in-turn, populate the AddIn collection parameter with host-side Document objects (as RemoteObject instances).

To illustrate, here's an add-in example calling this[typeof(Document), doctypedocs];:

         private void AppAddIn_Startup(object sender, EventArgs e)

        {

 

           IList<Document> doctypedocs = new List<Document>();

           int count = this[typeof(Document), doctypedocs];

           testdoc = doctypedocs[0];

           string dwgName2 = doctypedocs[0].Drawings[0].Name;

        }

Our design goal is for the Add-in author to pass a generic collection parameter to the host application and receive it back populated with host elements.  In this case, we’re using the generic collection ( System.Collections.Generic.IList<Document>) as the parameter passed to the host.

Copyright Summit Software Company, 2008. All rights reserved.