Exemplo n.º 1
0
        private void AddNamesInFile(string fileName)
        {
            var fileContent          = File.ReadAllText(fileName);
            var originalXamlDocument = new XamlDocument(fileContent);
            var newXamlDocument      = new XamlDocument(fileContent);

            Console.ForegroundColor = ConsoleColor.Gray;

            var moduleAcronym  = GenerateModuleAcronym(Path.GetFileName(fileName));
            var namingStrategy = new SerialElementNamingStrategy(moduleAcronym);

            var fragmentsToName = originalXamlDocument
                                  .Fragments()
                                  .Where(fragment => !fragment.IsAttachedProperty() &&
                                         !fragment.HasNameAttribute());

            foreach (var xamlFragment in fragmentsToName)
            {
                var namedXamlFragment = AddNameToFragment(namingStrategy, xamlFragment);

                newXamlDocument = newXamlDocument
                                  .ReplaceFragment(xamlFragment, namedXamlFragment);
            }

            if (newXamlDocument != originalXamlDocument)
            {
                File.WriteAllText(fileName, newXamlDocument.ToString());
            }
        }
Exemplo n.º 2
0
 protected bool Equals(XamlDocument other)
 {
     return(_xaml == other._xaml);
 }