Status: Open
Status: Answered
Status: Closed
Status: Duplicate

Accessing Metastorm objects from custom libraries

0
Posted Nov 08 by Piotr Perak.

Hi.

 

Instead of working in Metastorm designer we would prefer to use Visual Studio with Resharper. No matter how good Metastorm Designer is it will never be as good as he above pair.

 

We have no problems calling our custom libraries. I even succeeded modifying process variabels. I do it like that:

 

var ourCustomObject = new OurExternalLibrary.HaveAccessToVariables(Current.MapMBO);
ourCustomObjectb.SomeVariable = "some value";

 

in VS project we have

 

public class HaveAccessToVariables
 {
        private readonly IFieldAccess fieldAccess;

       public HaveAccessToVariables(IFieldAccess fieldAccess)
        {
            this.fieldAccess = fieldAccess;
        }

        public Text SomeVariable
        {
            get { return (Text) fieldAccess.GetField("SomeVariable "); }
            set { fieldAccess.SetField("SomeVariable ", value); }
        }

}

 

and it works perfectly. But I would also like to be able to pass Mstm object to my custom lib. But I don't know how to do that or if it is even possible at all.

 

I just tried to add Mstm as constructor parameter

 

using Metastorm.Runtime.Core;

 

public HaveAccessToVariables(IFieldAccess fieldAccess, Mstm mstm)
        {
            this.fieldAccess = fieldAccess;

            this.mstm = mstm;
        }

 

It compiles and publishes fine but during runtime it throws that it can't find Metastorm.Runtime.Core.Stub dll (which I had to reference on my dev machine to have access to Mstm class)

public class DostepDoZmiennych
    {
        private readonly IFieldAccess fieldAccess;

        public Text bsPolisaNr
        {
            get { return (Text) fieldAccess.GetField("bsPolisaNr"); }
            set { fieldAccess.SetField("bsPolisaNr", value); }
        }

1 Answer

0
BEST ANSWER: As chosen by the author.

Hi Piotr,

The way to do this is to have two class libraries. One is a stub, that you use in your designer\customlib, this is a .NET 3.5 Assembly.

The other copy is a .NET 4.0 Assembly which is copied to Deployment\CustomLib and Engine\Dotnetbin
Engine and deployment service must be stopped when rebuilding. Designer may need to be closed.

If you use the .NET 4.0 assembly in the designer directory – you won’t see it in the list of available namespace.
Basically the .NET 3.5 assembly should be a shell that just reflects the same methods.

Eg Assembly1 : DesignerNET35Stub references Metastorm.Runtime.Core.Stub

using Metastorm.Runtime.Core;
using System;
using System.Collections.Generic;
using System.Text;

namespace SharedNameSpace
{

public class MySharedClass
{
    private string myTestProperty;

    public string MyTestProperty
    {
    get{
        return myTestProperty; 
    }
    set{
        throw new NotImplementedException();
    }

    }

       }

}

Eg Assembly2 : EngineNET40Library is a .NET 4.0 Assembly referencing Metastorm.Runtime.Core

using Metastorm.Runtime.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedNameSpace
{

public class MySharedClass
{
    private string myTestProperty;

    public string MyTestProperty
    {
        get
        {
            return myTestProperty;
        }
        set
        {
            myTestProperty = value;
        }

    }

}
}

Depending on what you are doing you may want to reference Metastorm.Runtime.Contracts.

Hope this helps,
Rich


 You have subscribed and will receive email notifications of updates to this topic. To unsubscribe, uncheck the checkbox.

Statistics

Related categories

Your answer

To leave an answer, please sign in.