public VsixShellViewModel(ResourceManager resourceManager, ResourceViewModel resourceViewModel, ShellViewModel shellViewModel, IVsixCompatibility vsixCompatibility) { _resourceViewModel = resourceViewModel; _shellViewModel = shellViewModel; _vsixCompatibility = vsixCompatibility; resourceManager.Loaded += (_, __) => SelectedCodeGeneratorsChanged(); resourceViewModel.SelectedEntities.CollectionChanged += (_, __) => SelectedCodeGeneratorsChanged(); }
public MoveToResourceViewModel(IVsixCompatibility vsixCompatibility, ICollection <string> patterns, ICollection <ResourceEntity> resourceEntities, string text, string extension, string?className, string?functionName, string?fileName) { ResourceEntities = resourceEntities; SelectedResourceEntity = resourceEntities.FirstOrDefault(); ExistingEntries = resourceEntities .SelectMany(entity => entity.Entries) .Where(entry => entry.Values[null] == text) .ToArray(); ReuseExisting = ExistingEntries.Any(); SelectedResourceEntry = ExistingEntries.FirstOrDefault(); _extension = extension; Replacements = patterns.Select(p => new Replacement(p, pattern => vsixCompatibility.EvaluateMoveToResourcePattern(pattern, Key, ReuseExisting, SelectedResourceEntity, SelectedResourceEntry))).ToArray(); Keys = new[] { CreateKey(text, null, null), CreateKey(text, null, functionName), CreateKey(text, className ?? fileName, functionName) }.Distinct().ToArray(); Key = Keys.Skip(SelectedKeyIndex).FirstOrDefault() ?? Keys.FirstOrDefault(); Value = text; }