While working on a support case involving StarTeam and CaliberRM, I had to write a program to see which of the following scenario is true:
So guess what language I chose to use? Delphi! ;o)
Given:
var Folders: IStCollection; V: OleVariant;
and that Folders has an Items default property returning a IStCollection,
I had to cast Folders[ItemIndex]: OleVariant to another interface, IStFolder (var Folder: IStFolder)
So, I tried this:
Folder := Folders[ItemIndex];
and got “[Pascal Error] StarTeamFolderEnumerator.pas(70): E2010 Incompatible types: 'IStFolder' and 'OleVariant'”.
And this:
Folder := Folders[ItemIndex] as IStFolder;
and got “[Error] StarTeamFolderEnumeratorImpl.pas(61): E2015 Operator not applicable to this operand type”.
My good friend, Tim to the rescue again! It turns out that I have to cast Folders[ItemIndex] to an IDispatch first, before casting it to an IStFolder, because Folders[ItemIndex] is an OleVariant, which, in this case, is just an IDispatch.
V := Folders[ItemIndex];Folder := IDispatch(V) as IStFolder;
Tim explains,
“
”
In 2017, with the release of Delphi 10.2 Tokyo, Embarcadero introduced a specialized implementation of the Observer pattern into the System.Classes unit. While it has been in the wild for 9 years, it remains a "hidden" architecture for many, primarily because it serves as the invisible engine behind LiveBindings. Other than live bindings, you can also use the Observer pattern as a way to update component settings to the Windows registry, an .ini file, or persist it elsewhere.
System.Classes