Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: tmtm on August 26, 2009, 03:13:26 am
-
Is there any reason why IDualRepository.GetDiagramByGuid returns a result of type "object" instead of "EA.Diagram"?
All of the other IDualRepository.Get__ByGuid and IDualRepository.Get__ByID methods return their expected types. For example, IDualRepository.GetElementByGuid returns an "EA.Element" object.
Can the result be something other than of type "EA.Diagram"?
Thank you.
-
According to the documentation it should return a Diagram.
GetDiagramByGuid (string Guid)
Diagram
Returns a pointer to a diagram using the global reference ID (global ID). This is usually found using the diagram GUID property of an element, and stored for later use to open an diagram without using the collection GetAt() function.
Parameters:
Guid: String - the GUID of the diagram to locate.
-
Checked it on the latest version (848) and indeed the operation returns an object iso a Diagram.
You better report this as a bug.
Geert
-
Checked it on the latest version (848) and indeed the operation returns an object iso a Diagram.
You better report this as a bug.
Geert
As a matter of course we cast the return to an EA.Diagram, so the actual object reutrned is the "correct" diagram, but as Geert says, it's a bug...
-
The cautionary step Paolo uses is great for antibugging of course. But the way EA behaves is contrary to both the documentation and other similar operations. That's just plain wrong.
-
Thanks everyone. I've reported this as a bug. Not critical or anything. But it's good to have consistency.
-
As At 2023-10-14 I am seeing this bug in the latest version.
My question is how to do the casting from object to diagram? When I use
Diagram diagramDynamic = (Diagram) repository.GetDiagramByGuid(testDiagramGUID);
I get Visual Studio saying
Error CS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.Convert'