Beispiel #1
0
 public XamlDocument ReplaceFragment(XamlFragment originalXamlFragment, XamlFragment namedXamlFragment)
 {
     return(new XamlDocument(
                _xaml.ReplaceFirst(
                    originalXamlFragment.ToString(),
                    namedXamlFragment.ToString())));
 }
Beispiel #2
0
        private XamlFragment AddNameToFragment(INamingStrategy namingStrategy, XamlFragment xamlFragment)
        {
            var namedXamlFragment = namingStrategy.AddName(xamlFragment);

            if (namedXamlFragment != xamlFragment)
            {
                Console.Write(namedXamlFragment + Environment.NewLine);
            }

            return(namedXamlFragment);
        }
        public XamlFragment AddName(XamlFragment xamlFragment)
        {
            foreach (var elementName in _elementNames)
            {
                if (xamlFragment.Contains(elementName))
                {
                    var serialNumber = _elementSerialNumbers[elementName].ToString("D4");
                    _elementSerialNumbers[elementName]++;

                    var nameAttributeValue = $"{_moduleAcronym}_{elementName}_{serialNumber}";

                    var findValue    = "<" + elementName;
                    var replaceValue = findValue + $" x:Name=\"{nameAttributeValue}\"";

                    return(xamlFragment.Replace(findValue, replaceValue));
                }
            }

            return(xamlFragment);
        }
Beispiel #4
0
 protected bool Equals(XamlFragment other)
 {
     return(_xamlFragment == other._xamlFragment);
 }