public AudioProvider(FileInfo projectPath, GetFilePath getFilePath, Func <string, bool> fileLocationOk, IProject project, IAudioProviderCustomization customization) { m_projectPath = projectPath.Directory; m_project = project; m_customization = customization; Func <IEnumerable <Tuple <Id <FileInProject>, DocumentPath> >, IEnumerable <IAudioFile> > load = files => files.Select(file => new AudioFile(file.Item1, file.Item2, this)); Func <DirectoryInfo, AudioFile> makeEmpty = path => { throw new NotSupportedException("Can't create new audio files within the editor"); }; Func <Id <FileInProject>, MissingAudioFile> makeMissing = file => new MissingAudioFile(file, getFilePath(file), this); m_audioFiles = new ProjectElementList <IAudioFile>(getFilePath, fileLocationOk, load, makeEmpty, makeMissing); UpdateQueued = new SuppressibleAction(() => { ReallyUpdateUsage(); }); //For now just update everything }
/// <param name="context">Context used when localizing to reference current localization</param> /// <param name="usedGuids"></param> /// <param name="shouldClean"></param> /// <param name="shouldExpand"></param> /// <param name="pathOk">Path is an acceptable filename for a new localization file</param> /// <param name="fileLocationOk">Path is an acceptable location from which to import an existing localization file</param> public LocalizationEngine(GetFilePath getFilePath, IEnumerable <Project.TData.LocalizerSetData> sets, ILocalizationContext context, Func <HashSet <Id <LocalizedText> > > usedGuids, Func <string, bool> shouldClean, Func <FileInfo, bool> pathOk, Func <string, bool> fileLocationOk, UpToDateFile.BackEnd backEnd, DirectoryInfo origin) { m_context = context; m_usedGuids = usedGuids; ShouldClean = shouldClean; Func <IEnumerable <Tuple <Id <FileInProject>, DocumentPath> >, IEnumerable <ILocalizationFile> > load = files => { //return files.Select(file => LocalizationFile.Load(file, MakeSerializer(file.Name), backend)); var filesAndSerializer = files.Select(f => new { Id = f.Item1, Path = f.Item2, Serializer = MakeSerializer(f.Item2.AbsolutePath, f.Item1) }).ToList(); return(ParallelEnumerable.Select(filesAndSerializer.AsParallel(), fs => LocalizationFile.Load(fs.Path, fs.Id, fs.Serializer, backEnd))); }; Func <DirectoryInfo, LocalizationFile> makeEmpty = path => LocalizationFile.MakeNew(path, MakeSerializer, pathOk, backEnd, origin); m_localizers = new ProjectElementList <ILocalizationFile>(getFilePath, fileLocationOk.Bottleneck(), load, makeEmpty); m_localizationSets = sets.ToHashSet(); }