/// <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); }
/// <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); }