VSTA Integration Without using Proxygen and Wrapper Class, Feasible?

Latest post 06-24-2008 8:31 AM by Igor Soloydemko. 4 replies.
  • 01-14-2007 11:40 PM

    • aahkam
    • Top 50 Contributor
    • Joined on 12-26-2006
    • Posts 7

    VSTA Integration Without using Proxygen and Wrapper Class, Feasible?

    Dear All,

    I created the similar question in MSDN forum, but I was told that this would be a better place to seek for opinion and suggestion, hence I re-post it here again.

    Please refer to the original post here.

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1109340&SiteID=1

    Thank you.
    Filed under:
  • 01-16-2007 3:12 AM In reply to

    • aahkam
    • Top 50 Contributor
    • Joined on 12-26-2006
    • Posts 7

    Re: VSTA Integration Without using Proxygen and Wrapper Class, Feasible?

    Dear All,

    I eventually found out my own way of doing the proxy without using a wrapper class. (with some helps from proxygen, but will require one to edit and append some codes into the generated file)

    Step 1:
    For example, the proxy is generated using MyApplication.UI assembly, If I were to add an external type that was in MyApplication.DAL assembly, I create this class in my proxy.cs file.

    Eg.
    public partial class MyBaseClass : global::Microsoft.VisualStudio.Tools.Applications.IProxy
        {
            private global::Microsoft.VisualStudio.Tools.Applications.RemoteObject remoteObject;

            private global::System.Type remoteType;

            private global::System.Reflection.MemberInfo @__vstaCacheMyBaseVar01;

            internal virtual global::System.Type RemoteType
            {
                get
                {
                    return remoteType;
                }
                set
                {
                    if (remoteType == null)
                    {
                        remoteType = value;

                        if (string.CompareOrdinal(remoteType.FullName, "MyApplication.DAL.MyBaseClass") != 0)
                        {
                            remoteType = remoteType.BaseType;
                        }
                    }
                }
            }

            protected virtual string PrimaryCookie
            {
                get
                {
                    return "";
                }
            }

            global::System.AddIn.Contract.IContract global::Microsoft.VisualStudio.Tools.Applications.IProxy.Contract
            {
                get
                {
                    return ((global::Microsoft.VisualStudio.Tools.Applications.IProxy)this.RemoteObject).Contract;
                }
            }

            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
            [global::System.ComponentModel.BrowsableAttribute(false)]
            public MyBaseClass()
            {
            }
           
            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
            [global::System.ComponentModel.BrowsableAttribute(false)]
            public MyBaseClass(global::System.AddIn.Contract.IContract contract, global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager)
            {
                this.remoteObject = null;

                if (contract == null)
                    throw new global::System.ArgumentNullException("contract");
                if (typeInfrastructureManager == null)
                    throw new global::System.ArgumentNullException("typeInfrastructureManager");

                global::System.AddIn.Contract.Automation.IRemoteObjectContract remoteObjectContract =
                    (global::System.AddIn.Contract.Automation.IRemoteObjectContract)contract.QueryContract(typeof(global::System.AddIn.Contract.Automation.IRemoteObjectContract).AssemblyQualifiedName);

                remoteType = null;
                this.RemoteObject = new global::Microsoft.VisualStudio.Tools.Applications.RemoteObject(remoteObjectContract, typeInfrastructureManager);

                this.RemoteType = this.RemoteObject.GetType();
            }

            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
            [global::System.ComponentModel.BrowsableAttribute(false)]
            protected virtual global::Microsoft.VisualStudio.Tools.Applications.RemoteObject RemoteObject
            {
                get
                {
                    return this.remoteObject;
                }
                set
                {
                    this.remoteObject = value;
                }
            }

            public int MyBaseVar
            {
                get
                {
                    object[] _param = new object[0];
                    int retVal_param;
                    if ((this.@__vstaCacheMyBaseVar01 == null))
                    {
                        this.@__vstaCacheMyBaseVar01 = this.remoteType.GetProperty("MyBaseVar", (((global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance)
                                        | global::System.Reflection.BindingFlags.GetProperty)
                                        | global::System.Reflection.BindingFlags.Default), null, typeof(int), new global::System.Type[0], null);
                    }
                    retVal_param = ((int)(((global::System.Reflection.PropertyInfo)(this.@__vstaCacheMyBaseVar01)).GetValue(this, _param)));
                    return retVal_param;
                }
            }
        }


    Step 2:
    Ensure it has been added into the TypesMap in this function.
            public static global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager AddTypesToMap(global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager).

    Example: (Lines in Bold)

    namespace Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper {
       
       
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]
        [global::System.ComponentModel.BrowsableAttribute(false)]
        public sealed partial class CMyApplication_UIInitializer {
           
            public static global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager AddTypesToMap(global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager) {
                typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.ApplicationModel", typeof(global::MyApplication.Proxy.ApplicationModel));
                typeInfrastructureManager.TypeToCanonicalNameMap.Add(typeof(global::MyApplication.Proxy.ApplicationModel), "MyApplication.UI, MyApplication.UI.ApplicationModel");
                typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.ApplicationMainForm", typeof(global::MyApplication.Proxy.ApplicationMainForm));
                typeInfrastructureManager.TypeToCanonicalNameMap.Add(typeof(global::MyApplication.Proxy.ApplicationMainForm), "MyApplication.UI, MyApplication.UI.ApplicationMainForm");
                typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.FrameworkModel", typeof(global::MyApplication.Proxy.FrameworkModel));
                typeInfrastructureManager.TypeToCanonicalNameMap.Add(typeof(global::MyApplication.Proxy.FrameworkModel), "MyApplication.UI, MyApplication.UI.FrameworkModel");
                typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.WorksetModel", typeof(global::MyApplication.Proxy.WorksetModel));
                typeInfrastructureManager.TypeToCanonicalNameMap.Add(typeof(global::MyApplication.Proxy.WorksetModel), "MyApplication.UI, MyApplication.UI.WorksetModel");
                typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.AlgebraModel", typeof(global::MyApplication.Proxy.AlgebraModel));
                typeInfrastructureManager.TypeToCanonicalNameMap.Add(typeof(global::MyApplication.Proxy.AlgebraModel), "MyApplication.UI, MyApplication.UI.AlgebraModel");
                typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.DAL, MyApplication.DAL.MyBaseClass", typeof(global::MyApplication.Proxy.MyBaseClass));
                typeInfrastructureManager.TypeToCanonicalNameMap.Add(typeof(global::MyApplication.Proxy.MyBaseClass), "MyApplication.DAL, MyApplication.DAL.MyBaseClass");
                typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.Data, MyApplication.Data.MyClass", typeof(global::MyApplication.Proxy.MyClass));
                typeInfrastructureManager.TypeToCanonicalNameMap.Add(typeof(global::MyApplication.Proxy.MyClass), "MyApplication.Data, MyApplication.Data.MyClass");
                return typeInfrastructureManager;
            }
           
            internal static global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager GetMap() {
                global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager = new global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager();
                global::Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.CMyApplication_UIInitializer.AddTypesToMap(typeInfrastructureManager);
                return typeInfrastructureManager;
            }
        }
    }


    Step 3:
    In your Extension.cs file, add in the similar entry like how they are done in bold.

            private void InitializeTypeInfrastructureManager()
            {
                if (_typeInfrastructureManager == null)
                {
                    _typeInfrastructureManager = new global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager();
                    global::System.Type hostType;
                    global::System.Type proxyType;
                    hostType = typeof(global::MyApplication.UI.ApplicationModel);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.ApplicationModel>);
                    _typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.ApplicationModel", proxyType);
                    _typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.ApplicationModel");
                    hostType = typeof(global::MyApplication.UI.ApplicationMainForm);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.ApplicationMainForm>);
                    _typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.ApplicationMainForm", proxyType);
                    _typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.ApplicationMainForm");
                    hostType = typeof(global::MyApplication.UI.FrameworkModel);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.FrameworkModel>);
                    _typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.FrameworkModel", proxyType);
                    _typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.FrameworkModel");
                    hostType = typeof(global::MyApplication.UI.WorksetModel);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.WorksetModel>);
                    _typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.WorksetModel", proxyType);
                    _typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.WorksetModel");
                    hostType = typeof(global::MyApplication.UI.AlgebraModel);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.AlgebraModel>);
                    _typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.AlgebraModel", proxyType);
                    _typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.AlgebraModel");
                    hostType = typeof(global::MyApplication.DAL.MyBaseClass);
                    proxyType = typeof(NonProxiableType<global::MyApplication.DAL.MyBaseClass>);
                    _typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.DAL, MyApplication.DAL.MyBaseClass", proxyType);
                    _typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.DAL, MyApplication.DAL.MyBaseClass");
                    hostType = typeof(global::MyApplication.Data.MyClass);
                    proxyType = typeof(NonProxiableType<global::MyApplication.Data.MyClass>);
                    _typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.Data, MyApplication.Data.MyClass", proxyType);
                    _typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.Data, MyApplication.Data.MyClass");
                }
            }

            public sealed partial class CMyApplication_UIInitializer
            {

                public static global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager CreateTypeInfrastructureManager()
                {
                    global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager = new global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager();
                    global::System.Type hostType;
                    global::System.Type proxyType;
                    hostType = typeof(global::MyApplication.UI.ApplicationModel);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.ApplicationModel>);
                    typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.ApplicationModel", proxyType);
                    typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.ApplicationModel");
                    hostType = typeof(global::MyApplication.UI.ApplicationMainForm);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.ApplicationMainForm>);
                    typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.ApplicationMainForm", proxyType);
                    typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.ApplicationMainForm");
                    hostType = typeof(global::MyApplication.UI.FrameworkModel);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.FrameworkModel>);
                    typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.FrameworkModel", proxyType);
                    typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.FrameworkModel");
                    hostType = typeof(global::MyApplication.UI.WorksetModel);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.WorksetModel>);
                    typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.WorksetModel", proxyType);
                    typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.WorksetModel");
                    hostType = typeof(global::MyApplication.UI.AlgebraModel);
                    proxyType = typeof(NonProxiableType<global::MyApplication.UI.AlgebraModel>);
                    typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.UI, MyApplication.UI.AlgebraModel", proxyType);
                    typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.UI, MyApplication.UI.AlgebraModel");
                    hostType = typeof(global::MyApplication.DAL.MyBaseClass);
                    proxyType = typeof(NonProxiableType<global::MyApplication.DAL.MyBaseClass>);
                    typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.DAL, MyApplication.DAL.MyBaseClass", proxyType);
                    typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.DAL, MyApplication.DAL.MyBaseClass");

                    hostType = typeof(global::MyApplication.Data.MyClass);
                    proxyType = typeof(NonProxiableType<global::MyApplication.Data.MyClass>);
                    typeInfrastructureManager.CanonicalNameToTypeMap.Add("MyApplication.Data, MyApplication.Data.MyClass", proxyType);
                    typeInfrastructureManager.TypeToCanonicalNameMap.Add(hostType, "MyApplication.Data, MyApplication.Data.MyClass");
                    return typeInfrastructureManager;
                }
            }



    After all, we're done.

    :)




  • 01-16-2007 3:10 PM In reply to

    • Gary
    • Top 10 Contributor
    • Joined on 07-13-2006
    • Posts 318

    Re: VSTA Integration Without using Proxygen and Wrapper Class, Feasible?

    Because of transitive closure of types (types are completely isolated by the proxy layer)  the proxy's remoting must serialize any types contained in MyApplication.DAL.MyBaseClass.  Are there any additional contained types (other than intrinsics)?

    If there are, I would be interested to know if you can successfully use your hand-altered proxy layer.

    -G

  • 01-16-2007 8:58 PM In reply to

    • aahkam
    • Top 50 Contributor
    • Joined on 12-26-2006
    • Posts 7

    Re: VSTA Integration Without using Proxygen and Wrapper Class, Feasible?

    You may find it hard to believe, but yes, I tried types that are other than the intrinsics data type.

    Have a look to the full proxy.cs code. :D (Check out the AlgebraModel class, it contains the user defined type MyClass that is in the different assembly. Check out MyClass as well, it inherits from MyBaseClass that is again completely in another different assembly.)

    To what I had witness, it seems like "if the proxy knows how to marshall its type (local to proxy) to any external type (any external assembly type), given it in a different assembly or not is not an issue."

     

    Look at the complete proxy.cs file below: -

    //------------------------------------------------------------------------------

    // <auto-generated>

    // This code was generated by a tool.

    // Runtime Version:2.0.50727.42

    //

    // Changes to this file may cause incorrect behavior and will be lost if

    // the code is regenerated.

    // </auto-generated>

    //------------------------------------------------------------------------------

    [assembly: global::Microsoft.VisualStudio.Tools.Applications.RegistrationMethodAttribute(ClassName="Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.CMyApplication_UII" +

    "nitializer", MethodName="AddTypesToMap")]

    namespace MyApplication.Proxy {

    public partial class WorksetModel : global::Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract, global::Microsoft.VisualStudio.Tools.Applications.IProxy {

    private global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager = global::Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.CMyApplication_UIInitializer.GetMap();

    private global::Microsoft.VisualStudio.Tools.Applications.RemoteObject remoteObject;

    private global::System.Type remoteType;

    private global::System.Reflection.MemberInfo @__vstaCacheGetIntegerCollection0;

    private global::System.Reflection.MemberInfo @__vstaCacheGetDoubleCollection1;

    #region IEntryPointContract Members

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.FinishInitialization()

    {

    this.FinishInitialization();

    }

    global::System.AddIn.Contract.Automation.IRemoteObjectContract Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.GetEntryPointObject()

    {

    return new global::Microsoft.VisualStudio.Tools.Applications.RemoteObjectAdapter(this.GetType(), this, global::Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.CMyApplication_UIInitializer.GetMap());

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.Initialize()

    {

    this.OnStartup();

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.InitializeDataBindings()

    {

    this.InitializeDataBindings();

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.OnShutdown()

    {

    try

    {

    //call virtual method

    this.OnShutdown();

    }

    catch

    {

    throw;

    }

    finally

    {

    //then dispose of host context

    if (this.hostContextLock != null)

    {

    this.hostContextLock.Dispose();

    this.hostContextLock = null;

    }

    if (this.itemProviderLock != null)

    {

    this.itemProviderLock.Dispose();

    this.itemProviderLock = null;

    }

    }

    }

    #endregion

    #region IContract Members

    int global::System.AddIn.Contract.IContract.AcquireLifetimeToken()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    int global::System.AddIn.Contract.IContract.GetRemoteHashCode()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    global::System.AddIn.Contract.IContract global::System.AddIn.Contract.IContract.QueryContract(string contractIdentifier)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    bool global::System.AddIn.Contract.IContract.RemoteEquals(global::System.AddIn.Contract.IContract contract)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    string global::System.AddIn.Contract.IContract.RemoteToString()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    void global::System.AddIn.Contract.IContract.RevokeLifetimeToken(int token)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    #endregion

    #region Protected\Private fields

    private global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::System.AddIn.Contract.IServiceProviderContract> hostContextLock;

    private global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract> itemProviderLock;

    #endregion

     

     

     

    internal global::System.Type RemoteType

    {

    get

    {

    return remoteType;

    }

    set

    {

    if (remoteType == null)

    {

    remoteType = value;

    while (string.CompareOrdinal(remoteType.FullName, "MyApplication.UI.WorksetModel") != 0)

    {

    remoteType = remoteType.BaseType;

    }

    }

    }

    }

     

     

    global::System.AddIn.Contract.IContract global::Microsoft.VisualStudio.Tools.Applications.IProxy.Contract

    {

    get

    {

    return ((global::Microsoft.VisualStudio.Tools.Applications.IProxy)this.RemoteObject).Contract;

    }

    }

    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]

    [global::System.ComponentModel.BrowsableAttribute(false)]

    public WorksetModel(global::System.AddIn.Contract.IContract contract, global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager) {

    this.remoteObject = null;

    if (contract == null)

    throw new global::System.ArgumentNullException("contract");

    if (typeInfrastructureManager == null)

    throw new global::System.ArgumentNullException("typeInfrastructureManager");

    global::System.AddIn.Contract.Automation.IRemoteObjectContract remoteObjectContract =

    (global::System.AddIn.Contract.Automation.IRemoteObjectContract)contract.QueryContract(typeof(global::System.AddIn.Contract.Automation.IRemoteObjectContract).AssemblyQualifiedName);

    remoteType = null;

    this.RemoteObject = new global::Microsoft.VisualStudio.Tools.Applications.RemoteObject(remoteObjectContract, typeInfrastructureManager);

    this.RemoteType = this.RemoteObject.GetType();

    }

    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]

    [global::System.ComponentModel.BrowsableAttribute(false)]

    protected WorksetModel(global::System.AddIn.Contract.Collections.IRemoteArgumentArrayContract initArgs) {

    global::System.AddIn.Contract.IServiceProviderContract sp = ((global::System.AddIn.Contract.IServiceProviderContract)(initArgs.GetItem(0).ContractValue));

    global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract hip = ((global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract)(sp.QueryService(null, typeof(global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract).AssemblyQualifiedName)));

    global::System.AddIn.Contract.Automation.IRemoteObjectContract contract = ((global::System.AddIn.Contract.Automation.IRemoteObjectContract)(hip.GetHostObject("MyApplication.UI.WorksetModel", this.PrimaryCookie).QueryContract(typeof(global::System.AddIn.Contract.Automation.IRemoteObjectContract).AssemblyQualifiedName)));

    remoteType = null;

    RemoteObject = new global::Microsoft.VisualStudio.Tools.Applications.RemoteObject(contract, typeInfrastructureManager);

    RemoteType = this.RemoteObject.GetType();

    this.itemProviderLock = new global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract>(hip);

    this.hostContextLock = new global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::System.AddIn.Contract.IServiceProviderContract>(sp);

    this.typeInfrastructureManager.CacheProxy(this, contract, typeof(global::MyApplication.Proxy.WorksetModel), true);

    }

    protected virtual string PrimaryCookie {

    get {

    return "";

    }

    }

    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]

    [global::System.ComponentModel.BrowsableAttribute(false)]

    protected virtual global::Microsoft.VisualStudio.Tools.Applications.RemoteObject RemoteObject {

    get {

    return this.remoteObject;

    }

    set {

    this.remoteObject = value;

    }

    }

    protected virtual void OnStartup() {

    }

    protected virtual void InitializeDataBindings() {

    }

    protected virtual void FinishInitialization() {

    }

    protected virtual void OnShutdown() {

    }

    public int[] GetIntegerCollection() {

    object[] _param = new object[0];

    if ((this.@__vstaCacheGetIntegerCollection0 == null)) {

    this.@__vstaCacheGetIntegerCollection0 = this.remoteType.GetMethod("GetIntegerCollection", (((global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.InvokeMethod)

    | global::System.Reflection.BindingFlags.Instance)

    | global::System.Reflection.BindingFlags.Default), null, new global::System.Type[0], null);

    }

    int[] retVal_param;

    retVal_param = ((int[])(((global::System.Reflection.MethodInfo)(this.@__vstaCacheGetIntegerCollection0)).Invoke(this, _param)));

    return retVal_param;

    }

    public double[] GetDoubleCollection() {

    object[] _param = new object[0];

    if ((this.@__vstaCacheGetDoubleCollection1 == null)) {

    this.@__vstaCacheGetDoubleCollection1 = this.remoteType.GetMethod("GetDoubleCollection", (((global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.InvokeMethod)

    | global::System.Reflection.BindingFlags.Instance)

    | global::System.Reflection.BindingFlags.Default), null, new global::System.Type[0], null);

    }

    double[] retVal_param;

    retVal_param = ((double[])(((global::System.Reflection.MethodInfo)(this.@__vstaCacheGetDoubleCollection1)).Invoke(this, _param)));

    return retVal_param;

    }

    }

    public partial class FrameworkModel : global::Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract, global::Microsoft.VisualStudio.Tools.Applications.IProxy {

    private global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager = global::Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.CMyApplication_UIInitializer.GetMap();

    private global::Microsoft.VisualStudio.Tools.Applications.RemoteObject remoteObject;

    private global::System.Type remoteType;

    private global::System.Reflection.MemberInfo @__vstaCacheSummation1;

    private global::System.Reflection.MemberInfo @__vstaCacheCurrentWorksetModel2;

    #region IEntryPointContract Members

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.FinishInitialization()

    {

    this.FinishInitialization();

    }

    global::System.AddIn.Contract.Automation.IRemoteObjectContract Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.GetEntryPointObject()

    {

    return new global::Microsoft.VisualStudio.Tools.Applications.RemoteObjectAdapter(this.GetType(), this, global::Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.CMyApplication_UIInitializer.GetMap());

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.Initialize()

    {

    this.OnStartup();

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.InitializeDataBindings()

    {

    this.InitializeDataBindings();

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.OnShutdown()

    {

    try

    {

    //call virtual method

    this.OnShutdown();

    }

    catch

    {

    throw;

    }

    finally

    {

    //then dispose of host context

    if (this.hostContextLock != null)

    {

    this.hostContextLock.Dispose();

    this.hostContextLock = null;

    }

    if (this.itemProviderLock != null)

    {

    this.itemProviderLock.Dispose();

    this.itemProviderLock = null;

    }

    }

    }

    #endregion

    #region IContract Members

    int global::System.AddIn.Contract.IContract.AcquireLifetimeToken()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    int global::System.AddIn.Contract.IContract.GetRemoteHashCode()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    global::System.AddIn.Contract.IContract global::System.AddIn.Contract.IContract.QueryContract(string contractIdentifier)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    bool global::System.AddIn.Contract.IContract.RemoteEquals(global::System.AddIn.Contract.IContract contract)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    string global::System.AddIn.Contract.IContract.RemoteToString()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    void global::System.AddIn.Contract.IContract.RevokeLifetimeToken(int token)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    #endregion

    #region Protected\Private fields

    private global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::System.AddIn.Contract.IServiceProviderContract> hostContextLock;

    private global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract> itemProviderLock;

    #endregion

     

     

     

    internal global::System.Type RemoteType

    {

    get

    {

    return remoteType;

    }

    set

    {

    if (remoteType == null)

    {

    remoteType = value;

    while (string.CompareOrdinal(remoteType.FullName, "MyApplication.UI.FrameworkModel") != 0)

    {

    remoteType = remoteType.BaseType;

    }

    }

    }

    }

     

     

    global::System.AddIn.Contract.IContract global::Microsoft.VisualStudio.Tools.Applications.IProxy.Contract

    {

    get

    {

    return ((global::Microsoft.VisualStudio.Tools.Applications.IProxy)this.RemoteObject).Contract;

    }

    }

    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]

    [global::System.ComponentModel.BrowsableAttribute(false)]

    public FrameworkModel(global::System.AddIn.Contract.IContract contract, global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager) {

    this.remoteObject = null;

    if (contract == null)

    throw new global::System.ArgumentNullException("contract");

    if (typeInfrastructureManager == null)

    throw new global::System.ArgumentNullException("typeInfrastructureManager");

    global::System.AddIn.Contract.Automation.IRemoteObjectContract remoteObjectContract =

    (global::System.AddIn.Contract.Automation.IRemoteObjectContract)contract.QueryContract(typeof(global::System.AddIn.Contract.Automation.IRemoteObjectContract).AssemblyQualifiedName);

    remoteType = null;

    this.RemoteObject = new global::Microsoft.VisualStudio.Tools.Applications.RemoteObject(remoteObjectContract, typeInfrastructureManager);

    this.RemoteType = this.RemoteObject.GetType();

    }

    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]

    [global::System.ComponentModel.BrowsableAttribute(false)]

    protected FrameworkModel(global::System.AddIn.Contract.Collections.IRemoteArgumentArrayContract initArgs) {

    global::System.AddIn.Contract.IServiceProviderContract sp = ((global::System.AddIn.Contract.IServiceProviderContract)(initArgs.GetItem(0).ContractValue));

    global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract hip = ((global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract)(sp.QueryService(null, typeof(global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract).AssemblyQualifiedName)));

    global::System.AddIn.Contract.Automation.IRemoteObjectContract contract = ((global::System.AddIn.Contract.Automation.IRemoteObjectContract)(hip.GetHostObject("MyApplication.UI.FrameworkModel", this.PrimaryCookie).QueryContract(typeof(global::System.AddIn.Contract.Automation.IRemoteObjectContract).AssemblyQualifiedName)));

    remoteType = null;

    RemoteObject = new global::Microsoft.VisualStudio.Tools.Applications.RemoteObject(contract, typeInfrastructureManager);

    RemoteType = this.RemoteObject.GetType();

    this.itemProviderLock = new global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract>(hip);

    this.hostContextLock = new global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::System.AddIn.Contract.IServiceProviderContract>(sp);

    this.typeInfrastructureManager.CacheProxy(this, contract, typeof(global::MyApplication.Proxy.FrameworkModel), true);

    }

    protected virtual string PrimaryCookie {

    get {

    return "";

    }

    }

    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]

    [global::System.ComponentModel.BrowsableAttribute(false)]

    protected virtual global::Microsoft.VisualStudio.Tools.Applications.RemoteObject RemoteObject {

    get {

    return this.remoteObject;

    }

    set {

    this.remoteObject = value;

    }

    }

    public double Summation {

    get {

    object[] _param = new object[0];

    double retVal_param;

    if ((this.@__vstaCacheSummation1 == null)) {

    this.@__vstaCacheSummation1 = this.remoteType.GetProperty("Summation", (((global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance)

    | global::System.Reflection.BindingFlags.GetProperty)

    | global::System.Reflection.BindingFlags.Default), null, typeof(double), new global::System.Type[0], null);

    }

    retVal_param = ((double)(((global::System.Reflection.PropertyInfo)(this.@__vstaCacheSummation1)).GetValue(this, _param)));

    return retVal_param;

    }

    }

    public global::MyApplication.Proxy.WorksetModel CurrentWorksetModel {

    get {

    object[] _param = new object[0];

    global::MyApplication.Proxy.WorksetModel retVal_param;

    if ((this.@__vstaCacheCurrentWorksetModel2 == null)) {

    this.@__vstaCacheCurrentWorksetModel2 = this.remoteType.GetProperty("CurrentWorksetModel", (((global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.Instance)

    | global::System.Reflection.BindingFlags.GetProperty)

    | global::System.Reflection.BindingFlags.Default), null, typeof(global::MyApplication.Proxy.WorksetModel), new global::System.Type[0], null);

    }

    retVal_param = ((global::MyApplication.Proxy.WorksetModel)(((global::System.Reflection.PropertyInfo)(this.@__vstaCacheCurrentWorksetModel2)).GetValue(this, _param)));

    return retVal_param;

    }

    }

    protected virtual void OnStartup() {

    }

    protected virtual void InitializeDataBindings() {

    }

    protected virtual void FinishInitialization() {

    }

    protected virtual void OnShutdown() {

    }

    }

    public partial class ApplicationMainForm : global::Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract, global::Microsoft.VisualStudio.Tools.Applications.IProxy {

    private global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager = global::Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.CMyApplication_UIInitializer.GetMap();

    private global::Microsoft.VisualStudio.Tools.Applications.RemoteObject remoteObject;

    private global::System.Type remoteType;

    private global::System.Reflection.MemberInfo @__vstaCacheCurrentFrameworkModel1;

    #region IEntryPointContract Members

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.FinishInitialization()

    {

    this.FinishInitialization();

    }

    global::System.AddIn.Contract.Automation.IRemoteObjectContract Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.GetEntryPointObject()

    {

    return new global::Microsoft.VisualStudio.Tools.Applications.RemoteObjectAdapter(this.GetType(), this, global::Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper.CMyApplication_UIInitializer.GetMap());

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.Initialize()

    {

    this.OnStartup();

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.InitializeDataBindings()

    {

    this.InitializeDataBindings();

    }

    void Microsoft.VisualStudio.Tools.Applications.Contract.IEntryPointContract.OnShutdown()

    {

    try

    {

    //call virtual method

    this.OnShutdown();

    }

    catch

    {

    throw;

    }

    finally

    {

    //then dispose of host context

    if (this.hostContextLock != null)

    {

    this.hostContextLock.Dispose();

    this.hostContextLock = null;

    }

    if (this.itemProviderLock != null)

    {

    this.itemProviderLock.Dispose();

    this.itemProviderLock = null;

    }

    }

    }

    #endregion

    #region IContract Members

    int global::System.AddIn.Contract.IContract.AcquireLifetimeToken()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    int global::System.AddIn.Contract.IContract.GetRemoteHashCode()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    global::System.AddIn.Contract.IContract global::System.AddIn.Contract.IContract.QueryContract(string contractIdentifier)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    bool global::System.AddIn.Contract.IContract.RemoteEquals(global::System.AddIn.Contract.IContract contract)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    string global::System.AddIn.Contract.IContract.RemoteToString()

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    void global::System.AddIn.Contract.IContract.RevokeLifetimeToken(int token)

    {

    throw new global::System.Exception("The method or operation is not implemented.");

    }

    #endregion

    #region Protected\Private fields

    private global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::System.AddIn.Contract.IServiceProviderContract> hostContextLock;

    private global::Microsoft.VisualStudio.Tools.Applications.ContractLock<global::Microsoft.VisualStudio.Tools.Applications.Contract.IHostItemProviderContract> itemProviderLock;

    #endregion

     

     

     

    internal global::System.Type RemoteType

    {

    get

    {

    return remoteType;

    }

    set

    {

    if (remoteType == null)

    {

    remoteType = value;

    while (string.CompareOrdinal(remoteType.FullName, "MyApplication.UI.ApplicationMainForm") != 0)

    {

    remoteType = remoteType.BaseType;

    }

    }

    }

    }

     

     

    global::System.AddIn.Contract.IContract global::Microsoft.VisualStudio.Tools.Applications.IProxy.Contract

    {

    get

    {

    return ((global::Microsoft.VisualStudio.Tools.Applications.IProxy)this.RemoteObject).Contract;

    }

    }

    [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)]

    [global::System.ComponentModel.BrowsableAttribute(false)]

    public ApplicationMainForm(global::System.AddIn.Contract.IContract contract, global::Microsoft.VisualStudio.Tools.Applications.TypeInfrastructureManager typeInfrastructureManager) {