I have a problem that should be trivial, but I cannot find an elegant answer.
I have an instance IList<string>, and I want to get a string, separated by commas, of all its distinct (case-insensitive) values.
I thought I was just using an assistant string.Joinfor this, since it has a good overload that accepts the IEnumerator<string>as parameter . Unfortunately, I see that I am trapped: spring4d overrides IEnumerator<T>and, of course, uses its own type everywhere.
As a result, the following code does not compile:
var
distinct: system.IEnumerator<string>;
begin
result := inherited GetToken;
if assigned(result) then
begin
if not Modules.Contains(STR_DID_SESSION_MODULE) then
Modules.Add(STR_DID_SESSION_MODULE);
distinct := TDistinctIterator<string>.Create(Modules, TIStringComparer.Ordinal);
result.CustomClaims.Items[STR_CLAIM_CUSTOM_MODULES] := string.Join(',', distinct);
end;
end;
Assignment distinctfails withE2010 Incompatible types: 'System.IEnumerator<System.string>' and 'Spring.Collections.Extensions.TDistinctIterator<System.string>'
Alternatively, if I remove the namespace from different, it causes a call string.Join.
, ? ?