none
Add 'imports' to re-hosted designer

Answers

  • I know this is an old post.  But thought this may help someone.

    In Nick's example above the VisualBasic.SetSetting method is missing.  Here is a sample of how to programatically add an import to the root activity of a workflow on creation.

      Sequence sequence = new Sequence();
    
    
    
      VisualBasicSettings visualBasicSettings = new VisualBasicSettings();
    
      VisualBasicImportReference visualBasicImportReference = new VisualBasicImportReference();
    
      visualBasicImportReference.Assembly = "My.Assembly";
    
      visualBasicImportReference.Import = "My.Namespace";
    
      visualBasicSettings.ImportReferences.Add(visualBasicImportReference);
    
      VisualBasic.SetSettings(sequence, visualBasicSettings);
    
    
    
      WorkflowDesigner workFlowDesigner = new WorkflowDesigner();
    
      workFlowDesigner .Load(sequence);
    
    

    Tuesday, June 28, 2011 11:28 PM

All replies

  • Hello Nick, please follow think link.

    Basically the "Settings" property now behaves differently.

    1) Create your "settings" class, and add your own settings (ImportReferences)

    2) Use the shared member VisualBasic.SetSettings(targetActivity, yourSettings) to set up your settings.

        Dim settings As New VisualBasicSettings()
        'settings.ImportReferences.Add(...)
    
        ' ...
        VisualBasic.SetSettings(myActivity, settings)

    Hope it helps!

    Cheers

     


    Adriano
    Monday, June 14, 2010 7:08 AM
  • Hi Adriano

    Thanks for your reply.  I've tried adding that to my code, but it doesn't seem to work.  I was expecting to see in new 'imports' line in the workflow designer, but I don't get that.

    I am using the following code:

     string requiredAssemblyName = val.GetType().Assembly.GetName().Name;

     

    string requiredNamespace = val.GetType().Namespace;

     

    VisualBasicSettings vbs = new VisualBasicSettings();

     

    VisualBasicImportReference importRef = new VisualBasicImportReference();

     

     

     

     importRef.Assembly = requiredAssemblyName;

     importRef.Import = requiredNamespace;

     vbs.ImportReferences.Add(importRef);

     

     

     

     

     

     

    What am I doing wrong??

    Thanks

    Nick


    Nick C

     

     

     

     

     

     

     

     

     

     

     

    where 'val' is an instance of the new variable that I am adding to the workflow designer.
    VisualBasic.SetSettings(m_RootSequence, vbs);
    Monday, June 14, 2010 7:23 AM
  • Hi Nick, it looks like that the designer is not able to capture the change since it's not done through the "Model" proxies.

    Question: How are you adding the Variable to the designer? 

    If you use the

    ModelItem.Properties("Variables").Collection.Add(var)

    ... it should work, if not I guess that there is some currently not clear behavior on the rehosted Designer in this area.

    Hope it helps,

    Cheers


    Adriano
    Tuesday, June 15, 2010 7:19 AM
  • Hi Adriano

    I am using

    ModelItem.Properties("Variables").Collection.Add(var)

    to add my new variable; this works without issue.  If anyone else is reading this, here's a good blog that explains how you get to that line of code: http://blogs.msdn.com/b/mwinkle/archive/2009/11/06/finding-the-variables-in-scope-within-the-wf-designer.aspx

    However, when you do this, the designer adds the variable, but not its namespace.  Anyone know how to add a namespace through the model proxies?  If you inspect the model at runtime, it looks like all the classes you need haven't been made public.

    Regards

    Nick


    Nick C
    Thursday, June 17, 2010 7:36 AM
  • I know this is an old post.  But thought this may help someone.

    In Nick's example above the VisualBasic.SetSetting method is missing.  Here is a sample of how to programatically add an import to the root activity of a workflow on creation.

      Sequence sequence = new Sequence();
    
    
    
      VisualBasicSettings visualBasicSettings = new VisualBasicSettings();
    
      VisualBasicImportReference visualBasicImportReference = new VisualBasicImportReference();
    
      visualBasicImportReference.Assembly = "My.Assembly";
    
      visualBasicImportReference.Import = "My.Namespace";
    
      visualBasicSettings.ImportReferences.Add(visualBasicImportReference);
    
      VisualBasic.SetSettings(sequence, visualBasicSettings);
    
    
    
      WorkflowDesigner workFlowDesigner = new WorkflowDesigner();
    
      workFlowDesigner .Load(sequence);
    
    

    Tuesday, June 28, 2011 11:28 PM