private IFileTranslator GetTranslator(string fileExtension) { return(CacheService.GetCacheItem <IFileTranslator>("OptimusKeyGetTranslator" + fileExtension, configCacheSyncLock, TimeSpan.FromHours(6), delegate { var types = GetAllTypesUsingInterface(typeof(IFileTranslator)); foreach (var type in types) { IFileTranslator trans = Activator.CreateInstance(type) as IFileTranslator; if (trans.FileExtension == fileExtension) { return trans; } } return null; })); }
private List <IFileTranslator> GetTranslators(TranslatorType transType) { return(CacheService.GetCacheItem <List <IFileTranslator> >("OptimusKeyGetTranslators" + transType, configCacheSyncLock, TimeSpan.FromHours(6), delegate { var retVal = new List <IFileTranslator>(); var types = GetAllTypesUsingInterface(typeof(IFileTranslator)); foreach (var type in types) { IFileTranslator trans = Activator.CreateInstance(type) as IFileTranslator; if (trans.TranslatorType == transType) { retVal.Add(trans); } } return retVal; })); }