tag:blogger.com,1999:blog-11772075.post3761597548057921568..comments2023-07-05T09:02:00.033+01:00Comments on DelphiDabbler's Blog: SingletonsDelphidabblerhttp://www.blogger.com/profile/04753825418913482066noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-11772075.post-23097011354456914662010-08-18T21:31:34.830+01:002010-08-18T21:31:34.830+01:00Your string parameter overload for SingletonExists...<i>Your string parameter overload for SingletonExists won't work though</i><br /><br />Urgh, of course.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11772075.post-30678392979435078332010-08-17T19:07:18.175+01:002010-08-17T19:07:18.175+01:00Thanks Chris. You're right it would be (and is...Thanks Chris. You're right it would be (and is) better. I just didn't think of it!! Since I was converting code that used a string list for the mapping, I guess my mind was fixed on using a string key even though <em>TDictionary</em> doesn't need it.<br /><br />Your solution is much more elegant.<br /><br />Your string parameter overload for <em>SingletonExists</em> won't work Delphidabblerhttps://www.blogger.com/profile/04753825418913482066noreply@blogger.comtag:blogger.com,1999:blog-11772075.post-68329432173848605442010-08-15T14:12:15.202+01:002010-08-15T14:12:15.202+01:00Wouldn't it be better to match against the act...Wouldn't it be better to match against the actual class <b>type</b> rather than the class name? Off the top of my head, and using square not arrow brackets so that they actually show -<br /><br />class var fMap: TDictionary[TClass,TSingleton];<br />...<br />class function SingletonExists(const Cls: TClass): Boolean; overload; <br />class function SingletonExists(const ClsName: string): Anonymousnoreply@blogger.com