public bool Undo(string packageName, XmlNode xmlData)
        {
            bool result = true;

            // build XML string for all the installable components
            var sb = new StringBuilder("<Actions>");

            // loop through each of the appSettings keys
            foreach (var appKey in Settings.AppKeys)
            {
                sb.AppendFormat("<Action runat=\"install\" undo=\"true\" alias=\"HttpsRedirect_AddAppConfigKey\" key=\"{0}\" value=\"false\" />", appKey.Key);
            }

            // remove the dashboard control (if exists)
            sb.Append("<Action runat=\"install\" undo=\"true\" alias=\"addDashboardSection\" dashboardAlias=\"HttpsRedirectInstaller\" />");

            // append the closing tag
            sb.Append("</Actions>");

            // load the XML string into an XML document
            var actionsXml = new XmlDocument();

            actionsXml.LoadXml(sb.ToString());

            // loop through each of the installable components
            foreach (XmlNode node in actionsXml.DocumentElement.SelectNodes("//Action"))
            {
                // uninstall the components
                PackageAction.UndoPackageAction("HttpsRedirect", node.Attributes["alias"].Value, node);
            }

            return(result);
        }
Пример #2
0
 /// <summary>
 /// Uninstalls the action.
 /// </summary>
 /// <param name="packageAlias">The package alias.</param>
 /// <param name="node">The node.</param>
 /// <param name="result">The result.</param>
 private static void UnInstallAction(string packageAlias, XmlNode node, List <PackageActionResult> result)
 {
     try
     {
         PackageAction.UndoPackageAction("Packageactiontester", packageAlias, node);
         result.Add(new PackageActionResult {
             Alias = packageAlias, Result = "Uninstalled"
         });
     }
     catch (Exception ex)
     {
         result.Add(new PackageActionResult {
             Alias = packageAlias, Result = string.Format("Error uninstalling: {0}", ex)
         });
     }
 }
Пример #3
0
        /// <summary>
        /// Undoes the specified package name.
        /// </summary>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="xmlData">The XML data.</param>
        /// <returns>Returns <c>true</c> when successful, otherwise <c>false</c>.</returns>
        public bool Undo(string packageName, XmlNode xmlData)
        {
            var result = true;

            // build XML string for all the installable components
            var sb = new StringBuilder("<Actions>");

            // list of AppSettings keys to uninstall
            var appSettingsKeys = new List <string>()
            {
                Constants.AppKey_DragAndDrop,
                Constants.AppKey_KeyboardShortcuts,
                Constants.AppKey_RazorModelBinding,
                Constants.AppKey_TrayPeek
            };

            // loop through each of the appSettings keys (e.g. UI Modules and Razor Model Binding)
            foreach (var appSettingsKey in appSettingsKeys)
            {
                sb.AppendFormat("<Action runat=\"install\" undo=\"true\" alias=\"{0}\" key=\"{1}\" value=\"false\" />", AddAppConfigKey.ActionAlias, appSettingsKey);
            }

            // get the UI Modules
            sb.AppendFormat("<Action runat=\"install\" undo=\"true\" alias=\"{0}\" />", AddHttpModule.ActionAlias);

            // find the NotFoundHandlers
            var notFoundHandlersNamespace = "uComponents.NotFoundHandlers";
            var notFoundHandlersAssembly  = Assembly.Load(notFoundHandlersNamespace);

            if (notFoundHandlersAssembly != null)
            {
                var notFoundHandlersTypes = notFoundHandlersAssembly.GetTypes();
                if (notFoundHandlersTypes != null)
                {
                    var notFoundHandlersAction = "<Action runat=\"install\" undo=\"true\" alias=\"{0}\" assembly=\"{1}\" type=\"{2}\" />";
                    foreach (var type in notFoundHandlersTypes)
                    {
                        if (string.Equals(type.Namespace, notFoundHandlersNamespace) && type.FullName.StartsWith(notFoundHandlersNamespace))
                        {
                            sb.AppendFormat(notFoundHandlersAction, Add404Handler.ActionAlias, notFoundHandlersNamespace, type.FullName.Substring(notFoundHandlersNamespace.Length + 1));
                            continue;
                        }
                    }
                }
            }

            // find the XSLT extensions
            var xsltExtensionsNamespace = "uComponents.XsltExtensions";
            var xsltExtensionsAssembly  = Assembly.Load(xsltExtensionsNamespace);

            if (xsltExtensionsAssembly != null)
            {
                var xsltExtensionsTypes = xsltExtensionsAssembly.GetTypes();
                if (xsltExtensionsTypes != null)
                {
                    var xsltExtensionsAction = "<Action runat=\"install\" undo=\"true\" alias=\"addXsltExtension\" assembly=\"{0}\" type=\"{1}\" extensionAlias=\"ucomponents.{2}\" />";
                    foreach (var type in xsltExtensionsTypes)
                    {
                        if (string.Equals(type.Namespace, xsltExtensionsNamespace) && type.IsPublic && !type.IsSerializable)
                        {
                            sb.AppendFormat(xsltExtensionsAction, xsltExtensionsNamespace, type.FullName, type.Name.ToLower());
                            continue;
                        }
                    }
                }
            }

            // remove the dashboard control (if exists)
            sb.Append("<Action runat=\"install\" undo=\"true\" alias=\"addDashboardSection\" dashboardAlias=\"uComponentsInstaller\" />");

            // append the closing tag
            sb.Append("</Actions>");

            // load the XML string into an XML document
            var actionsXml = new XmlDocument();

            actionsXml.LoadXml(sb.ToString());

            // loop through each of the installable components
            foreach (XmlNode node in actionsXml.DocumentElement.SelectNodes("//Action"))
            {
                // uninstall the components
                PackageAction.UndoPackageAction(Constants.ApplicationName, node.Attributes["alias"].Value, node);
            }

            return(result);
        }