private static XpathReplacement ProcessAddAction(string xpathPath, string rawActionString)
        {
            XpathReplacement newReplacement;

            newReplacement = new XpathReplacement
            {
                Xpath    = xpathPath,
                Action   = XpathReplacement.ActionType.Add,
                NewValue = rawActionString.Replace(ActionPrefixAdd, "")
            };
            return(newReplacement);
        }
        private static XpathReplacement ProcessUpdateAttributeAction(string xpathPath, string rawActionString, XpathReplacement newReplacement)
        {
            var splitArray = rawActionString.Replace(ActionPrefixUpdateAttribute, "").Split(ActionPrefixUpdateAttributeSpliter);

            if (splitArray.Count() == 2)
            {
                newReplacement = new XpathReplacement
                {
                    Xpath          = xpathPath,
                    Action         = XpathReplacement.ActionType.UpdateAttribute,
                    AttributenName = splitArray[0],
                    NewValue       = splitArray[1]
                };
            }

            return(newReplacement);
        }
        public void ReplaceAnyValuesFromAppSettings(XmlNode rootNode)
        {
            var overrideXPathSettings  = GetRawSitecorePatchConfigs();
            var settingXPathCollection = new List <XpathReplacement>();

            if (overrideXPathSettings.Any())
            {
                foreach (var oxs in overrideXPathSettings)
                {
                    var xpathPath       = ConfigurationManager.AppSettings[oxs];
                    var actionKey       = oxs.Replace(XpathSettingEndWithKey, "") + ActionSettingEndWithKey;
                    var rawActionString = ConfigurationManager.AppSettings[actionKey];
                    if (!string.IsNullOrEmpty(rawActionString))
                    {
                        var newReplacement = new XpathReplacement();

                        if (rawActionString.StartsWith(ActionPrefixAdd))
                        {
                            newReplacement = ProcessAddAction(xpathPath, rawActionString);
                        }
                        else if (rawActionString.StartsWith(ActionPrefixUpdatetext))
                        {
                            newReplacement = ProcessUpdateTextAction(xpathPath, rawActionString);
                        }
                        else if (rawActionString.StartsWith(ActionPrefixUpdateAttribute))
                        {
                            newReplacement = ProcessUpdateAttributeAction(xpathPath, rawActionString, newReplacement);
                        }
                        else if (rawActionString.StartsWith(ActionPrefixRemove))
                        {
                            newReplacement = ProcessRemoveAction(xpathPath);
                        }

                        if (newReplacement.IsValid())
                        {
                            settingXPathCollection.Add(newReplacement);
                        }
                    }
                }
                ProcessReplacements(rootNode, settingXPathCollection);
            }
        }