I have a bundles of data which are passed as parameters to some functions and returned as output from some functions. The bundle itself has no processing, so it could be defined as a structure as easily as a class/interface.
What is the best way to pass this bundle through the Pipeline? Using an Interface appears to have the overhead of needing an extraneous implementation class on the AddIn side. However, I can't get a Structure to be accepted by the PipelineBuilder.
If I specify my bundle as an Interface in my contracts, it looks like I need to create a class on the add-in side to implement the generated AddInViews Interface.
Public Interface IMyBundleAsContract
Property Name() as String
Property Value() as Object
If I specify my bundle as a Structure in my contracts, the PipelineBuilder is indicating I need exactly one constructor (from ValidateStructContract).
Public Structure IMyBundleAsStructure
Dim m_Name as String
Dim m_Value as Object
Passing as a structure means you're passing by value, whereas defining contracts will have by-reference semantics. Passing as contracts gives you greater flexibility with respect to versioning over time, but at the cost of complexity.
I don't use PipelineBuilder, so can't really comment on how well it handles structures.
You shouldn't be using Object in a struct. You should instead use a serializable type from a framework assembly.
As for the error message, have you tried adding a constructor like the following?
m_Name = name
m_Value = value
Thanks for the heads up on the Object, it was not necessary so I got rid of it.
As for adding a New statement to the contract, I wasn't expecting I could put code in the Structure (in C++, a struct is just a storage definition so I was confused).
Just in case someone else looks at this, there are two other things you need to do to make a structure work: make it Serializable and have a Property with
the exact same name as the constructor parameter. Here's a simplified one parameter example.
Public Structure IMyStructure
Dim m_Name As String
Public Sub New(ByVal Name As String)
m_Name = newName
Public Property Name() As String
Name = m_Name
Set(ByVal value As String)
m_Name = value