示例#1
0
        private void FixReferenceInXamlFiles(
            Dictionary <string, NamespaceInfo> namespaceRenameDict,
            HashSet <INamedTypeSymbol> processedTypes
            )
        {
            if (namespaceRenameDict is null)
            {
                throw new ArgumentNullException(nameof(namespaceRenameDict));
            }

            if (processedTypes is null)
            {
                throw new ArgumentNullException(nameof(processedTypes));
            }

            foreach (var xamlFilePath in _xamlFilePaths)
            {
                if (!xamlFilePath.EndsWith(".xaml"))
                {
                    continue;
                }

                var xamlEngine = new XamlEngine(xamlFilePath);

                foreach (var processedType in processedTypes)
                {
                    var targetNamespaceInfo = namespaceRenameDict[processedType.ContainingNamespace.ToDisplayString()];

                    xamlEngine.MoveObject(
                        processedType.ContainingNamespace.ToDisplayString(),
                        processedType.Name,
                        targetNamespaceInfo.ModifiedName
                        );
                }

                xamlEngine.SaveIfChangesExists();
            }
        }
示例#2
0
        public bool Adjust()
        {
            var xamlEngine = new XamlEngine(_subjectFilePath);

            if (!xamlEngine.GetRootInfo(out var rootNamespace, out var rootName))
            {
                return(false);
            }

            if (rootNamespace == _targetNamespace)
            {
                return(false);
            }

            xamlEngine.MoveObject(
                rootNamespace !,
                rootName !,
                _targetNamespace
                );

            xamlEngine.SaveIfChangesExists();

            return(true);
        }