/// <summary>
 /// Intializes a new instance of the <see cref="RegistryDetector"/>
 /// with the specified root <see cref="RegistryKeyBase"/>.
 /// </summary>
 /// <param name="rootKey">
 /// The root key.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// If <c>rootKey</c> is <c>null</c>.
 /// </exception>
 public RegistryDetector(RegistryKeyBase rootKey)
 {
     if (rootKey == null)
     {
         throw new ArgumentNullException("rootKey");
     }
     _rootKey = rootKey;
 }
 /// <summary>
 /// Get the .NET 4.0 profiles.
 /// </summary>
 private static DotNetProfiles Get40Profiles(
     RegistryKeyBase key,
     RegistryDetection detection
     )
 {
     return detection.FullProfileDetected ?
         DotNetProfiles.ClientFull :
         DotNetProfiles.Client;
 }
 /// <summary>
 /// Get the .NET 3.0 service packs.
 /// </summary>
 private static IEnumerable<Version> Get3ServicePack(
     RegistryKeyBase key,
     RegistryDetection detection
     )
 {
     var parentKeyName = RegistryKeyBase.GetParentName(
         key.Hive,
         detection.FullProfileRegistryKeyName
     );
     if (!key.MatchRegistryValue(parentKeyName, "Install", 1))
     {
         return new Version[0];
     }
     return GetServicePacks(key, parentKeyName, "SP");
 }
 /// <summary>
 /// Get the .NET service packs.
 /// </summary>
 internal static IEnumerable<Version> GetServicePacks(
     RegistryKeyBase key,
     string subKeyName,
     string valueName
     )
 {
     return key.MatchRegistryValue(subKeyName, valueName, 1) ?
         new[] { new Version("1.0") } :
         key.MatchRegistryValue(subKeyName, valueName, 2) ?
             new[] { new Version("1.0"), new Version("2.0") } :
             new Version[0];
 }
 /// <summary>
 /// Get the .NET service packs.
 /// </summary>
 internal static IEnumerable<Version> GetServicePacks(
     RegistryKeyBase key,
     RegistryDetection detection
     )
 {
     var keyName = detection.FullProfileRegistryKeyName;
     return GetServicePacks(key, keyName, "SP");
 }
 /// <summary>
 /// Detects if the Microsoft .NET Framework version represented by this
 /// detection is installed.
 /// </summary>
 /// <param name="rootKey">
 /// The root <see cref="RegistryKeyBase"/>.
 /// </param>
 /// <returns>
 /// The detected .NET version or <c>null</c> if the version was
 /// not detected.
 /// </returns>
 public DotNetVersion Detect(RegistryKeyBase rootKey)
 {
     Validate();
     var fullProfileRegistryKeyName = FullProfileRegistryKeyName;
     var clientProfileRegistryKeyName = ClientProfileRegistryKeyName;
     var fullProfileDetected =
         FullProfileDetected = fullProfileRegistryKeyName != null &&
         rootKey.MatchRegistryValue(
             fullProfileRegistryKeyName,
             FullProfileValueName,
             FullProfileValue
         );
     var clientProfileDetected = ClientProfileDetected =
         fullProfileDetected || (
             clientProfileRegistryKeyName != null &&
             rootKey.MatchRegistryValue(
                 clientProfileRegistryKeyName,
                 ClientProfileValueName,
                 ClientProfileValue
             )
         );
     if (!fullProfileDetected && !clientProfileDetected)
     {
         return null;
     }
     if (GetServicePacksDelegate != null)
     {
         VersionBuilder.ServicePacks =
             GetServicePacksDelegate(rootKey, this);
     }
     if (GetProfilesDelegate != null)
     {
         VersionBuilder.Profiles = GetProfilesDelegate(rootKey, this);
     }
     return VersionBuilder.DotNetVersion;
 }