예제 #1
0
        private void ManageFileUids(XamlFileDescription xamlFileDescription)
        {
            using (var textReader = visualStudioAdapter.GetXamlFileContent(xamlFileDescription))
            {
                var uidCollector = new UidManager(xamlFileDescription.Name, textReader, localizabilityChecker).ParseFileSmart();

                if (uidCollector.Count > 0)
                {
                    switch (ManageUidOperation)
                    {
                    case ManageUidOperation.CheckUid:
                        var fvm = new XamlFileViewModel(solutionFolder, xamlFileDescription, uidCollector);
                        ThreadTools.InvokeInUIThread(Window, () => InvalidFiles.Add(fvm));
                        break;

                    case ManageUidOperation.UpdateUid:
                        if (!uidCollector.AllAreValid())
                        {
                            //TODO: resolve duplicates

                            UpdateFileUids(xamlFileDescription, uidCollector);

                            var fvm1 = new XamlFileViewModel(solutionFolder, xamlFileDescription, null);
                            ThreadTools.InvokeInUIThread(Window, () => InvalidFiles.Add(fvm1));
                        }
                        break;

                    case ManageUidOperation.RemoveUid:
                        if (!uidCollector.AllAreAbsent())
                        {
                            UpdateFileUids(xamlFileDescription, uidCollector);
                            var fvm2 = new XamlFileViewModel(solutionFolder, xamlFileDescription, null);
                            ThreadTools.InvokeInUIThread(Window, () => InvalidFiles.Add(fvm2));
                        }
                        break;

                    case ManageUidOperation.PrepareTranslation:
                        bamlResourceCollector.Add(xamlFileDescription, uidCollector);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
        }