How do I access the property of a .NET Assembly that is of another Class type defined in the same assembly?
1 次查看(过去 30 天)
显示 更早的评论
I have a custom .NET assembly provided by a HW vendor to read the output of their custom data format. Let's call it A7Parser. It has a bunch of classes - FileConverter, Project, Run, SensorData, and TestSequence.
When I run one of the methods of FileConverter on the custom datafile, I can read/import that into MATLAB as a structure, which itself is of the data type Project (as defined by the subclass). But most of the fields of this structure are string, but some of them are of the type defined by other classes of A7Parser: Run, SensorData and TestSequence.
In the workspace, these fields show up as System.Collections.Generic.Lists<A7Parser*TestSequence>, for instance. That property has values as defined by the TestSequence class.
How can I extract those values from this field?
I can separately instantiate a variable of that class, using
tas = asm1.AssemblyHandle.GetType('A7Parser.TestSequence')
sa = System.Activator.CreateInstance(tas);
But I can't seem to extract that field value as a TestSequence class structure. Any ideas?
0 个评论
回答(1 个)
Jaskirat
2025-1-28
Hello,
I understand that you are working with a “.NET” assembly inside MATLAB, and the objective is to try and extract and work with values from a “System.Collections.Generic.List<A7Parser.TestSequence>”.
Here is a general approach that can be followed to do so
1)Access the list using the “.” operator.
testSequenceList=project.field;
2)Convert list to array.
listSize=testSequenceList.Count;
testSequences=cell(1,listSize);
followed by extracting elements using an iterative loop.
for i=1:listSize
testSequences{i}=testSequenceList.Item(i-1)
end
3)Access fields of TestSequence object using “.” operator.
The following answer might be useful-
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!