Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to increment the RunCount option for the specified version of the specified Type
        /// </summary>
        /// <param name="configuration">The configuration in which the option will be found</param>
        /// <param name="type">The Type for which the RunCount value will be incremented</param>
        /// <returns></returns>
        public static bool IncrementRunCountForVersionOfType(XmlConfiguration configuration, Type type, out DateTime installDate, out int runCount)
        {
            installDate = DateTime.Now;
            runCount    = 0;
            try
            {
                XmlConfigurationCategory category = InstallationEngine.GetExistingCategoryForTypeVersion(configuration, type, CategoryNames.Installed);
                if (category != null)
                {
                    XmlConfigurationOption option = null;

                    option = category.Options[@"InstallDate"];
                    if (option != null)
                    {
                        installDate = (DateTime)option.Value;
                    }

                    option = category.Options[@"RunCount"];
                    if (option != null)
                    {
                        // retrieve, increment, and set the run count
                        runCount = (int)option.Value;
                        runCount++;
                        option.Value = runCount;
                    }
                }
            }
            catch (System.Exception systemException)
            {
                System.Diagnostics.Trace.WriteLine(systemException);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static bool RemoveUninstalledEntryForType(XmlConfiguration configuration, Type type)
        {
            XmlConfigurationCategory category = null;

            // find and remove the install category for this type
            category = InstallationEngine.GetExistingCategoryForTypeVersion(configuration, type, CategoryNames.Uninstalled);
            if (category != null)
            {
                category.Remove();
                category = null;
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an installation record for the specified Type
        /// </summary>
        /// <param name="configuration">The configuration in which the category will be created</param>
        /// <param name="type">The type for which the category will be created</param>
        /// <returns></returns>
        public static XmlConfigurationCategory InstallVersionOfType(XmlConfiguration configuration, Type type, out DateTime installDate)
        {
            installDate = DateTime.Now;

            // remove the uninstall entry for the type
            InstallationEngine.RemoveUninstalledEntryForType(configuration, type);

            // create the install entry for the type
            XmlConfigurationCategory category = InstallationEngine.CreateCategoryForTypeVersion(configuration, type, CategoryNames.Installed);

            if (category != null)
            {
                XmlConfigurationOption option = null;

                // create the install date
                option = category.Options[@"InstallDate"];
                if (option == null)
                {
                    option                      = category.Options[@"InstallDate", true, installDate];
                    option.Category             = @"Installation Notes";
                    option.Description          = @"This date marks the date and time on which the SnapIn was installed.";
                    option.ShouldSerializeValue = true;
                }
                option = null;

                // create the run count
                option = category.Options[@"RunCount"];
                if (option == null)
                {
                    option             = category.Options[@"RunCount", true, 0];
                    option.Category    = @"Installation Notes";
                    option.Description = @"This number indicates the number of times the SnapIn has executed.";
                }
                option = null;
            }
            return(category);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates an uninstallation record for the specified Type
        /// </summary>
        /// <param name="configuration">The configuration in which the category will be created</param>
        /// <param name="type">The type for which the category will be created</param>
        /// <returns></returns>
        public static XmlConfigurationCategory UninstallVersionOfType(XmlConfiguration configuration, Type type)
        {
            // remove the install entry for the type
            InstallationEngine.RemoveInstalledEntryForType(configuration, type);

            // create the uninstall entry for the type
            XmlConfigurationCategory category = InstallationEngine.CreateCategoryForTypeVersion(configuration, type, CategoryNames.Uninstalled);

            if (category != null)
            {
                XmlConfigurationOption option = null;

                // create the install date
                option = category.Options[@"UninstallDate"];
                if (option == null)
                {
                    option             = category.Options[@"UninstallDate", true, DateTime.Now.ToString()];
                    option.Category    = @"Installation Notes";
                    option.Description = @"This date marks the date and time on which the SnapIn was uninstalled.";
                }
                option = null;
            }
            return(category);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Parses the "Uninstalled" category in the configuration specified for the type specified, and returns an array of Versions for each Version of the Type that is listed as "Uninstalled"
 /// </summary>
 /// <param name="configuration">The configuration to parse</param>
 /// <param name="type">The type to search for</param>
 /// <returns></returns>
 public static Version[] GetUninstalledVersionsOfType(XmlConfiguration configuration, Type type)
 {
     return(InstallationEngine.GetListedVersionsOfType(configuration, type, CategoryNames.Uninstalled));
 }