See http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-csharp/63887/C-typeof-and-Generics
On Jul 16, 6:28 pm, Josh Rogers <[email protected]> wrote: > I apologize in advance that this may be a bit out of the scope of this > group, but I figured this would be my best chance of getting an answer > as I assume someone has run into this before. I have a factory class > that returns a specific data mapper depending upon the type that I > pass it, using generics, the code is as such: > > public static IDataMapper<T> GetMapper<T>() where T: IDto > { > Type mapperType = MapperLocator.GetMapper(typeof(T)); > > return > (IDataMapper<T>)mapperType.Assembly.CreateInstance(mapperType.FullName); > } > > However when I intercept the method call and want to retrieve the > datamapper it won't compile because generics require a known type at > compile time from what I understand. Is there some way to get around > this or is there another strategy that you know of that I could > achieve the same result? > > Thanks, > Josh --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
