System.Data.SQLite
Check-in [2398c28918]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:More refactoring, eliminate all static data pertaining to .NET Framework and/or Visual Studio versions, replacing them with the POD classes FrameworkList and VsList.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | VsInstallerWork
Files: files | file ages | folders
SHA1: 2398c28918b11df67342e0b0382910ac2158e36a
User & Date: mistachkin 2012-01-03 04:48:42
Context
2012-01-03
04:53
Move the InitializeVsPackage method where it should be. check-in: b34bcad2c0 user: mistachkin tags: VsInstallerWork
04:48
More refactoring, eliminate all static data pertaining to .NET Framework and/or Visual Studio versions, replacing them with the POD classes FrameworkList and VsList. check-in: 2398c28918 user: mistachkin tags: VsInstallerWork
2012-01-02
12:14
Work on making the installer tool verify that the core assembly is supported by the requested versions of Visual Studio (i.e. based on the image runtime version). check-in: 16872024de user: mistachkin tags: VsInstallerWork
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tools/install/Installer.cs.

    54     54       );
    55     55   
    56     56       ///////////////////////////////////////////////////////////////////////////
    57     57   
    58     58       internal delegate bool VisualStudioRegistryCallback(
    59     59           RegistryKey rootKey,
    60     60           Version vsVersion,
    61         -        Guid packageId,
    62         -        Guid serviceId,
    63         -        Guid dataSourceId,
    64         -        Guid dataProviderId,
           61  +        Installer.Package package,
    65     62           object clientData,
    66     63           bool whatIf,
    67     64           bool verbose,
    68     65           ref string error
    69     66       );
    70     67       #endregion
    71     68   
................................................................................
  1290   1287                   // do nothing.
  1291   1288               }
  1292   1289           }
  1293   1290           #endregion
  1294   1291   
  1295   1292           ///////////////////////////////////////////////////////////////////////
  1296   1293   
         1294  +        #region Package Class
         1295  +        internal sealed class Package
         1296  +        {
         1297  +            #region Public Constructors
         1298  +            public Package()
         1299  +            {
         1300  +                // do nothing.
         1301  +            }
         1302  +            #endregion
         1303  +
         1304  +            ///////////////////////////////////////////////////////////////////
         1305  +
         1306  +            #region Public Properties
         1307  +            private Guid packageId;
         1308  +            public Guid PackageId
         1309  +            {
         1310  +                get { return packageId; }
         1311  +                set { packageId = value; }
         1312  +            }
         1313  +
         1314  +            ///////////////////////////////////////////////////////////////////
         1315  +
         1316  +            private Guid serviceId;
         1317  +            public Guid ServiceId
         1318  +            {
         1319  +                get { return serviceId; }
         1320  +                set { serviceId = value; }
         1321  +            }
         1322  +
         1323  +            ///////////////////////////////////////////////////////////////////
         1324  +
         1325  +            private Guid dataSourceId;
         1326  +            public Guid DataSourceId
         1327  +            {
         1328  +                get { return dataSourceId; }
         1329  +                set { dataSourceId = value; }
         1330  +            }
         1331  +
         1332  +            ///////////////////////////////////////////////////////////////////
         1333  +
         1334  +            private Guid dataProviderId;
         1335  +            public Guid DataProviderId
         1336  +            {
         1337  +                get { return dataProviderId; }
         1338  +                set { dataProviderId = value; }
         1339  +            }
         1340  +
         1341  +            ///////////////////////////////////////////////////////////////////
         1342  +
         1343  +            private Guid adoNetTechnologyId;
         1344  +            public Guid AdoNetTechnologyId
         1345  +            {
         1346  +                get { return adoNetTechnologyId; }
         1347  +                set { adoNetTechnologyId = value; }
         1348  +            }
         1349  +            #endregion
         1350  +        }
         1351  +        #endregion
         1352  +
         1353  +        ///////////////////////////////////////////////////////////////////////
         1354  +
  1297   1355           #region Configuration Class
  1298   1356           private sealed class Configuration
  1299   1357           {
  1300   1358               #region Private Constants
  1301   1359               private const char Switch = '-';
  1302   1360               private const char AltSwitch = '/';
  1303   1361   
................................................................................
  2137   2195                   return false;
  2138   2196               }
  2139   2197   
  2140   2198               ///////////////////////////////////////////////////////////////////
  2141   2199   
  2142   2200               public static bool CheckImageRuntimeVersion(
  2143   2201                   Configuration configuration,
  2144         -                VersionListMap fromtoyou,
  2145         -                VersionList versionList,
         2202  +                VsList vsList,
  2146   2203                   bool strict,
  2147   2204                   ref string error
  2148   2205                   )
  2149   2206               {
  2150   2207                   try
  2151   2208                   {
  2152   2209                       if (configuration == null)
................................................................................
  2500   2557               {
  2501   2558                   get { return confirm; }
  2502   2559                   set { confirm = value; }
  2503   2560               }
  2504   2561               #endregion
  2505   2562           }
  2506   2563           #endregion
         2564  +
         2565  +        ///////////////////////////////////////////////////////////////////////
         2566  +
         2567  +        #region FrameworkList Class
         2568  +        private sealed class FrameworkList
         2569  +        {
         2570  +            #region Public Constructors
         2571  +            public FrameworkList()
         2572  +            {
         2573  +                // do nothing.
         2574  +            }
         2575  +            #endregion
         2576  +
         2577  +            ///////////////////////////////////////////////////////////////////
         2578  +
         2579  +            #region Public Methods
         2580  +            private RegistryKey rootKey;
         2581  +            public RegistryKey RootKey
         2582  +            {
         2583  +                get { return rootKey; }
         2584  +                set { rootKey = value; }
         2585  +            }
         2586  +
         2587  +            ///////////////////////////////////////////////////////////////////
         2588  +
         2589  +            private StringList names;
         2590  +            public StringList Names
         2591  +            {
         2592  +                get { return names; }
         2593  +                set { names = value; }
         2594  +            }
         2595  +
         2596  +            ///////////////////////////////////////////////////////////////////
         2597  +
         2598  +            private VersionMap versions;
         2599  +            public VersionMap Versions
         2600  +            {
         2601  +                get { return versions; }
         2602  +                set { versions = value; }
         2603  +            }
         2604  +
         2605  +            ///////////////////////////////////////////////////////////////////
         2606  +
         2607  +            private StringList platformNames;
         2608  +            public StringList PlatformNames
         2609  +            {
         2610  +                get { return platformNames; }
         2611  +                set { platformNames = value; }
         2612  +            }
         2613  +            #endregion
         2614  +        }
         2615  +        #endregion
         2616  +
         2617  +        ///////////////////////////////////////////////////////////////////////
         2618  +
         2619  +        #region VsList Class
         2620  +        private sealed class VsList
         2621  +        {
         2622  +            #region Public Constructors
         2623  +            public VsList()
         2624  +            {
         2625  +                // do nothing.
         2626  +            }
         2627  +            #endregion
         2628  +
         2629  +            ///////////////////////////////////////////////////////////////////
         2630  +
         2631  +            #region Public Properties
         2632  +            private RegistryKey rootKey;
         2633  +            public RegistryKey RootKey
         2634  +            {
         2635  +                get { return rootKey; }
         2636  +                set { rootKey = value; }
         2637  +            }
         2638  +
         2639  +            ///////////////////////////////////////////////////////////////////
         2640  +
         2641  +            private VersionList versions;
         2642  +            public VersionList Versions
         2643  +            {
         2644  +                get { return versions; }
         2645  +                set { versions = value; }
         2646  +            }
         2647  +
         2648  +            ///////////////////////////////////////////////////////////////////
         2649  +
         2650  +            private VersionListMap frameworkVersions;
         2651  +            public VersionListMap FrameworkVersions
         2652  +            {
         2653  +                get { return frameworkVersions; }
         2654  +                set { frameworkVersions = value; }
         2655  +            }
         2656  +
         2657  +            ///////////////////////////////////////////////////////////////////
         2658  +
         2659  +            private VersionList installedVersions;
         2660  +            public VersionList InstalledVersions
         2661  +            {
         2662  +                get { return installedVersions; }
         2663  +                set { installedVersions = value; }
         2664  +            }
         2665  +            #endregion
         2666  +        }
         2667  +        #endregion
  2507   2668           #endregion
  2508   2669   
  2509   2670           ///////////////////////////////////////////////////////////////////////
  2510   2671   
  2511   2672           #region Private Constant Data
  2512   2673           private const string CoreFileName = "System.Data.SQLite.dll";
  2513   2674           private const string LinqFileName = "System.Data.SQLite.Linq.dll";
................................................................................
  2557   2718           #region Private Data
  2558   2719           private static Assembly thisAssembly = Assembly.GetExecutingAssembly();
  2559   2720   
  2560   2721           private static string traceCategory = Path.GetFileName(
  2561   2722               thisAssembly.Location);
  2562   2723   
  2563   2724           private static TraceCallback traceCallback = AppTrace;
  2564         -
  2565         -        ///////////////////////////////////////////////////////////////////////
  2566         -
  2567         -        private static RegistryKey frameworkRootKey;
  2568         -        private static StringList frameworkNameList;
  2569         -        private static VersionMap frameworkVersionMap;
  2570         -        private static StringList platformNameList;
  2571         -
  2572         -        ///////////////////////////////////////////////////////////////////////
  2573         -
  2574         -        private static RegistryKey vsRootKey;
  2575         -        private static VersionList vsVersionList;
  2576         -        private static VersionListMap vsFrameworkVersionMap;
  2577         -        private static Guid? vsPackageId;
  2578         -        private static Guid? vsServiceId;
  2579         -        private static Guid? vsDataSourcesId;
  2580         -        private static Guid? vsDataProviderId;
  2581         -        private static Guid? vsAdoNetTechnologyId;
  2582   2725           #endregion
  2583   2726   
  2584   2727           ///////////////////////////////////////////////////////////////////////
  2585   2728   
  2586   2729           #region Trace Handling
  2587   2730           private static string GetLogFileName()
  2588   2731           {
................................................................................
  2647   2790               return result;
  2648   2791           }
  2649   2792           #endregion
  2650   2793   
  2651   2794           ///////////////////////////////////////////////////////////////////////
  2652   2795   
  2653   2796           #region .NET Framework Handling
         2797  +        private static string GetImageRuntimeVersion(
         2798  +            string fileName
         2799  +            )
         2800  +        {
         2801  +            try
         2802  +            {
         2803  +                Assembly assembly =
         2804  +                    Assembly.ReflectionOnlyLoadFrom(fileName); /* throw */
         2805  +
         2806  +                if (assembly != null)
         2807  +                    return assembly.ImageRuntimeVersion;
         2808  +            }
         2809  +            catch
         2810  +            {
         2811  +                // do nothing.
         2812  +            }
         2813  +
         2814  +            return null;
         2815  +        }
         2816  +
         2817  +        ///////////////////////////////////////////////////////////////////////
         2818  +
  2654   2819           private static string GetFrameworkDirectory(
  2655   2820               RegistryKey rootKey,
  2656   2821               Version frameworkVersion,
  2657   2822               bool whatIf,
  2658   2823               bool verbose
  2659   2824               )
  2660   2825           {
................................................................................
  2794   2959               return null;
  2795   2960           }
  2796   2961           #endregion
  2797   2962   
  2798   2963           ///////////////////////////////////////////////////////////////////////
  2799   2964   
  2800   2965           #region Per-Framework/Platform Handling
  2801         -        private static void ResetAllFrameworks()
  2802         -        {
  2803         -            frameworkRootKey = null;
  2804         -
  2805         -            if (frameworkNameList != null)
  2806         -            {
  2807         -                frameworkNameList.Clear();
  2808         -                frameworkNameList = null;
  2809         -            }
  2810         -
  2811         -            if (frameworkVersionMap != null)
  2812         -            {
  2813         -                frameworkVersionMap.Clear();
  2814         -                frameworkVersionMap = null;
  2815         -            }
  2816         -        }
  2817         -
  2818         -        ///////////////////////////////////////////////////////////////////////
  2819         -
  2820         -        private static void InitializeAllFrameworks(
  2821         -            Configuration configuration
  2822         -            )
  2823         -        {
  2824         -            if (frameworkRootKey == null)
  2825         -                frameworkRootKey = Registry.LocalMachine;
  2826         -
  2827         -            if (frameworkNameList == null)
  2828         -            {
  2829         -                frameworkNameList = new StringList();
         2966  +        private static void InitializeFrameworkList(
         2967  +            Configuration configuration,
         2968  +            ref FrameworkList frameworkList
         2969  +            )
         2970  +        {
         2971  +            if (frameworkList == null)
         2972  +                frameworkList = new FrameworkList();
         2973  +
         2974  +            if (frameworkList.RootKey == null)
         2975  +                frameworkList.RootKey = Registry.LocalMachine;
         2976  +
         2977  +            ///////////////////////////////////////////////////////////////////
         2978  +
         2979  +            if (frameworkList.Names == null)
         2980  +            {
         2981  +                frameworkList.Names = new StringList();
         2982  +
         2983  +                if ((configuration == null) || !configuration.NoDesktop)
         2984  +                    frameworkList.Names.Add(".NETFramework");
         2985  +
         2986  +                if ((configuration == null) || !configuration.NoCompact)
         2987  +                {
         2988  +                    frameworkList.Names.Add(".NETCompactFramework");
         2989  +                    frameworkList.Names.Add(".NETCompactFramework");
         2990  +                    frameworkList.Names.Add(".NETCompactFramework");
         2991  +                }
         2992  +            }
         2993  +
         2994  +            ///////////////////////////////////////////////////////////////////
         2995  +
         2996  +            if (frameworkList.Versions == null)
         2997  +            {
         2998  +                frameworkList.Versions = new VersionMap();
         2999  +
         3000  +                if ((configuration == null) || !configuration.NoDesktop)
         3001  +                {
         3002  +                    VersionList desktopVersionList = new VersionList();
         3003  +
         3004  +                    if ((configuration == null) || !configuration.NoNetFx20)
         3005  +                        desktopVersionList.Add(new Version(2, 0, 50727));
         3006  +
         3007  +                    if ((configuration == null) || !configuration.NoNetFx40)
         3008  +                        desktopVersionList.Add(new Version(4, 0, 30319));
         3009  +
         3010  +                    frameworkList.Versions.Add(".NETFramework",
         3011  +                        desktopVersionList);
         3012  +                }
         3013  +
         3014  +                if ((configuration == null) || !configuration.NoCompact)
         3015  +                {
         3016  +                    frameworkList.Versions.Add(".NETCompactFramework",
         3017  +                        new VersionList(new Version[] {
         3018  +                        new Version(2, 0, 0, 0), new Version(3, 5, 0, 0)
         3019  +                    }));
         3020  +                }
         3021  +            }
         3022  +
         3023  +            ///////////////////////////////////////////////////////////////////
         3024  +
         3025  +            if (frameworkList.PlatformNames == null)
         3026  +            {
         3027  +                frameworkList.PlatformNames = new StringList();
  2830   3028   
  2831   3029                   if ((configuration == null) || !configuration.NoDesktop)
  2832         -                    frameworkNameList.Add(".NETFramework");
         3030  +                    frameworkList.PlatformNames.Add(null);
  2833   3031   
  2834   3032                   if ((configuration == null) || !configuration.NoCompact)
  2835   3033                   {
  2836         -                    frameworkNameList.Add(".NETCompactFramework");
  2837         -                    frameworkNameList.Add(".NETCompactFramework");
  2838         -                    frameworkNameList.Add(".NETCompactFramework");
  2839         -                }
  2840         -            }
  2841         -
  2842         -            if (frameworkVersionMap == null)
  2843         -                frameworkVersionMap = new VersionMap();
  2844         -
  2845         -            if ((configuration == null) || !configuration.NoDesktop)
  2846         -            {
  2847         -                VersionList desktopVersionList = new VersionList();
  2848         -
  2849         -                if ((configuration == null) || !configuration.NoNetFx20)
  2850         -                    desktopVersionList.Add(new Version(2, 0, 50727));
  2851         -
  2852         -                if ((configuration == null) || !configuration.NoNetFx40)
  2853         -                    desktopVersionList.Add(new Version(4, 0, 30319));
  2854         -
  2855         -                frameworkVersionMap.Add(".NETFramework", desktopVersionList);
  2856         -            }
  2857         -
  2858         -            if ((configuration == null) || !configuration.NoCompact)
  2859         -            {
  2860         -                frameworkVersionMap.Add(".NETCompactFramework",
  2861         -                    new VersionList(new Version[] {
  2862         -                    new Version(2, 0, 0, 0), new Version(3, 5, 0, 0)
  2863         -                }));
  2864         -            }
  2865         -
  2866         -            if (platformNameList == null)
  2867         -            {
  2868         -                platformNameList = new StringList();
  2869         -
  2870         -                if ((configuration == null) || !configuration.NoDesktop)
  2871         -                    platformNameList.Add(null);
  2872         -
  2873         -                if ((configuration == null) || !configuration.NoCompact)
  2874         -                {
  2875         -                    platformNameList.Add("PocketPC");
  2876         -                    platformNameList.Add("Smartphone");
  2877         -                    platformNameList.Add("WindowsCE");
         3034  +                    frameworkList.PlatformNames.Add("PocketPC");
         3035  +                    frameworkList.PlatformNames.Add("Smartphone");
         3036  +                    frameworkList.PlatformNames.Add("WindowsCE");
  2878   3037                   }
  2879   3038               }
  2880   3039           }
  2881   3040   
  2882   3041           ///////////////////////////////////////////////////////////////////////
  2883   3042   
  2884   3043           private static bool HaveFramework(
................................................................................
  2918   3077                   return true;
  2919   3078               }
  2920   3079           }
  2921   3080   
  2922   3081           ///////////////////////////////////////////////////////////////////////
  2923   3082   
  2924   3083           private static bool ForEachFrameworkConfig(
         3084  +            FrameworkList frameworkList,
  2925   3085               FrameworkConfigCallback callback,
  2926   3086               string invariant,
  2927   3087               string name,
  2928   3088               string description,
  2929   3089               string typeName,
  2930   3090               AssemblyName assemblyName,
  2931   3091               object clientData,
  2932   3092               bool whatIf,
  2933   3093               bool verbose,
  2934   3094               ref bool saved,
  2935   3095               ref string error
  2936   3096               )
  2937   3097           {
  2938         -            RegistryKey rootKey = frameworkRootKey;
         3098  +            if (frameworkList == null)
         3099  +            {
         3100  +                error = "invalid framework list";
         3101  +                return false;
         3102  +            }
         3103  +
         3104  +            RegistryKey rootKey = frameworkList.RootKey;
  2939   3105   
  2940   3106               if (rootKey == null)
  2941   3107               {
  2942   3108                   error = "invalid root key";
  2943   3109                   return false;
  2944   3110               }
  2945   3111   
................................................................................
  2946   3112               if (!Object.ReferenceEquals(rootKey, Registry.CurrentUser) &&
  2947   3113                   !Object.ReferenceEquals(rootKey, Registry.LocalMachine))
  2948   3114               {
  2949   3115                   error = "root key must be per-user or per-machine";
  2950   3116                   return false;
  2951   3117               }
  2952   3118   
  2953         -            if (frameworkNameList == null)
         3119  +            if (frameworkList.Names == null)
  2954   3120               {
  2955   3121                   error = "no framework names found";
  2956   3122                   return false;
  2957   3123               }
  2958   3124   
  2959         -            if (frameworkVersionMap == null)
         3125  +            if (frameworkList.Versions == null)
  2960   3126               {
  2961   3127                   error = "no framework versions found";
  2962   3128                   return false;
  2963   3129               }
  2964   3130   
  2965         -            if (platformNameList == null)
         3131  +            if (frameworkList.PlatformNames == null)
  2966   3132               {
  2967   3133                   error = "no platform names found";
  2968   3134                   return false;
  2969   3135               }
  2970   3136   
  2971         -            if (frameworkNameList.Count != platformNameList.Count)
         3137  +            if (frameworkList.Names.Count != frameworkList.PlatformNames.Count)
  2972   3138               {
  2973   3139                   error = String.Format("framework name count {0} does not " +
  2974         -                    "match platform name count {1}", frameworkNameList.Count,
  2975         -                    platformNameList.Count);
         3140  +                    "match platform name count {1}", frameworkList.Names.Count,
         3141  +                    frameworkList.PlatformNames.Count);
  2976   3142   
  2977   3143                   return false;
  2978   3144               }
  2979   3145   
  2980         -            for (int index = 0; index < frameworkNameList.Count; index++)
         3146  +            for (int index = 0; index < frameworkList.Names.Count; index++)
  2981   3147               {
  2982   3148                   //
  2983   3149                   // NOTE: Grab the name of the framework (e.g. ".NETFramework")
  2984   3150                   //       and the name of the platform (e.g. "WindowsCE").
  2985   3151                   //
  2986         -                string frameworkName = frameworkNameList[index];
  2987         -                string platformName = platformNameList[index];
         3152  +                string frameworkName = frameworkList.Names[index];
         3153  +                string platformName = frameworkList.PlatformNames[index];
  2988   3154   
  2989   3155                   //
  2990   3156                   // NOTE: Skip all non-desktop frameworks (i.e. if the platform
  2991   3157                   //       name is not null).
  2992   3158                   //
  2993   3159                   if (platformName != null)
  2994   3160                       continue;
................................................................................
  2995   3161   
  2996   3162                   //
  2997   3163                   // NOTE: Grab the supported versions of this particular
  2998   3164                   //       framework.
  2999   3165                   //
  3000   3166                   VersionList frameworkVersionList;
  3001   3167   
  3002         -                if (!frameworkVersionMap.TryGetValue(
         3168  +                if (!frameworkList.Versions.TryGetValue(
  3003   3169                           frameworkName, out frameworkVersionList) ||
  3004   3170                       (frameworkVersionList == null))
  3005   3171                   {
  3006   3172                       continue;
  3007   3173                   }
  3008   3174   
  3009   3175                   foreach (Version frameworkVersion in frameworkVersionList)
................................................................................
  3097   3263   
  3098   3264               return true;
  3099   3265           }
  3100   3266   
  3101   3267           ///////////////////////////////////////////////////////////////////////
  3102   3268   
  3103   3269           private static bool ForEachFrameworkRegistry(
         3270  +            FrameworkList frameworkList,
  3104   3271               FrameworkRegistryCallback callback,
  3105   3272               object clientData,
  3106   3273               bool whatIf,
  3107   3274               bool verbose,
  3108   3275               ref string error
  3109   3276               )
  3110   3277           {
  3111         -            RegistryKey rootKey = frameworkRootKey;
         3278  +            if (frameworkList == null)
         3279  +            {
         3280  +                error = "invalid framework list";
         3281  +                return false;
         3282  +            }
         3283  +
         3284  +            RegistryKey rootKey = frameworkList.RootKey;
  3112   3285   
  3113   3286               if (rootKey == null)
  3114   3287               {
  3115   3288                   error = "invalid root key";
  3116   3289                   return false;
  3117   3290               }
  3118   3291   
................................................................................
  3119   3292               if (!Object.ReferenceEquals(rootKey, Registry.CurrentUser) &&
  3120   3293                   !Object.ReferenceEquals(rootKey, Registry.LocalMachine))
  3121   3294               {
  3122   3295                   error = "root key must be per-user or per-machine";
  3123   3296                   return false;
  3124   3297               }
  3125   3298   
  3126         -            if (frameworkNameList == null)
         3299  +            if (frameworkList.Names == null)
  3127   3300               {
  3128   3301                   error = "no framework names found";
  3129   3302                   return false;
  3130   3303               }
  3131   3304   
  3132         -            if (frameworkVersionMap == null)
         3305  +            if (frameworkList.Versions == null)
  3133   3306               {
  3134   3307                   error = "no framework versions found";
  3135   3308                   return false;
  3136   3309               }
  3137   3310   
  3138         -            if (platformNameList == null)
         3311  +            if (frameworkList.PlatformNames == null)
  3139   3312               {
  3140   3313                   error = "no platform names found";
  3141   3314                   return false;
  3142   3315               }
  3143   3316   
  3144         -            if (frameworkNameList.Count != platformNameList.Count)
         3317  +            if (frameworkList.Names.Count != frameworkList.PlatformNames.Count)
  3145   3318               {
  3146   3319                   error = String.Format("framework name count {0} does not " +
  3147         -                    "match platform name count {1}", frameworkNameList.Count,
  3148         -                    platformNameList.Count);
         3320  +                    "match platform name count {1}", frameworkList.Names.Count,
         3321  +                    frameworkList.PlatformNames.Count);
  3149   3322   
  3150   3323                   return false;
  3151   3324               }
  3152   3325   
  3153         -            for (int index = 0; index < frameworkNameList.Count; index++)
         3326  +            for (int index = 0; index < frameworkList.Names.Count; index++)
  3154   3327               {
  3155   3328                   //
  3156   3329                   // NOTE: Grab the name of the framework (e.g. ".NETFramework")
  3157   3330                   //       and the name of the platform (e.g. "WindowsCE").
  3158   3331                   //
  3159         -                string frameworkName = frameworkNameList[index];
  3160         -                string platformName = platformNameList[index];
         3332  +                string frameworkName = frameworkList.Names[index];
         3333  +                string platformName = frameworkList.PlatformNames[index];
  3161   3334   
  3162   3335                   //
  3163   3336                   // NOTE: Grab the supported versions of this particular
  3164   3337                   //       framework.
  3165   3338                   //
  3166   3339                   VersionList frameworkVersionList;
  3167   3340   
  3168         -                if (!frameworkVersionMap.TryGetValue(
         3341  +                if (!frameworkList.Versions.TryGetValue(
  3169   3342                           frameworkName, out frameworkVersionList) ||
  3170   3343                       (frameworkVersionList == null))
  3171   3344                   {
  3172   3345                       continue;
  3173   3346                   }
  3174   3347   
  3175   3348                   foreach (Version frameworkVersion in frameworkVersionList)
................................................................................
  3208   3381               return true;
  3209   3382           }
  3210   3383           #endregion
  3211   3384   
  3212   3385           ///////////////////////////////////////////////////////////////////////
  3213   3386   
  3214   3387           #region Per-Visual Studio Version Handling
  3215         -        private static void InitializeVsRootKeyAndIds()
  3216         -        {
  3217         -            if (vsRootKey == null)
  3218         -                vsRootKey = Registry.LocalMachine;
  3219         -
  3220         -            if (vsAdoNetTechnologyId == null)
  3221         -                vsAdoNetTechnologyId = new Guid(
  3222         -                    "77AB9A9D-78B9-4BA7-91AC-873F5338F1D2");
  3223         -
  3224         -            if (vsPackageId == null)
  3225         -                vsPackageId = new Guid(
  3226         -                    "DCBE6C8D-0E57-4099-A183-98FF74C64D9C");
  3227         -
  3228         -            if (vsServiceId == null)
  3229         -                vsServiceId = new Guid(
  3230         -                    "DCBE6C8D-0E57-4099-A183-98FF74C64D9D");
  3231         -
  3232         -            if (vsDataSourcesId == null)
  3233         -                vsDataSourcesId = new Guid(
  3234         -                    "0EBAAB6E-CA80-4B4A-8DDF-CBE6BF058C71");
  3235         -
  3236         -            if (vsDataProviderId == null)
  3237         -                vsDataProviderId = new Guid(
  3238         -                    "0EBAAB6E-CA80-4B4A-8DDF-CBE6BF058C70");
  3239         -        }
  3240         -
  3241         -        ///////////////////////////////////////////////////////////////////////
  3242         -
  3243         -        private static void ResetVsFrameworkVersionMap()
  3244         -        {
  3245         -            if (vsFrameworkVersionMap != null)
  3246         -            {
  3247         -                vsFrameworkVersionMap.Clear();
  3248         -                vsFrameworkVersionMap = null;
  3249         -            }
  3250         -        }
  3251         -
  3252         -        ///////////////////////////////////////////////////////////////////////
  3253         -
  3254         -        private static void InitializeVsFrameworkVersionMap(
  3255         -            Configuration configuration
  3256         -            )
  3257         -        {
  3258         -            if (vsFrameworkVersionMap == null)
  3259         -            {
  3260         -                vsFrameworkVersionMap = new VersionListMap();
  3261         -
  3262         -                // vsFrameworkVersionMap.Add(new Version(8, 0),
         3388  +        private static void InitializeVsList(
         3389  +            Configuration configuration,
         3390  +            ref VsList vsList
         3391  +            )
         3392  +        {
         3393  +            if (vsList == null)
         3394  +                vsList = new VsList();
         3395  +
         3396  +            if (vsList.RootKey == null)
         3397  +                vsList.RootKey = Registry.LocalMachine;
         3398  +
         3399  +            if (vsList.Versions == null)
         3400  +            {
         3401  +                vsList.Versions = new VersionList();
         3402  +
         3403  +                // vsList.Versions.Add(new Version(8, 0)); // Visual Studio 2005
         3404  +
         3405  +                if ((configuration == null) || !configuration.NoVs2008)
         3406  +                    vsList.Versions.Add(new Version(9, 0)); // Visual Studio 2008
         3407  +
         3408  +                if ((configuration == null) || !configuration.NoVs2010)
         3409  +                    vsList.Versions.Add(new Version(10, 0));// Visual Studio 2010
         3410  +            }
         3411  +
         3412  +            if (vsList.FrameworkVersions == null)
         3413  +            {
         3414  +                vsList.FrameworkVersions = new VersionListMap();
         3415  +
         3416  +                // vsList.FrameworkVersions.Add(new Version(8, 0),
  3263   3417                   //     new VersionList(new Version[] {
  3264   3418                   //         new Version(2, 0, 50727) }));
  3265   3419   
  3266   3420                   if ((configuration == null) || !configuration.NoVs2008)
  3267         -                    vsFrameworkVersionMap.Add(new Version(9, 0),
         3421  +                    vsList.FrameworkVersions.Add(new Version(9, 0),
  3268   3422                           new VersionList(new Version[] {
  3269   3423                               new Version(2, 0, 50727) }));
  3270   3424   
  3271   3425                   if ((configuration == null) || !configuration.NoVs2010)
  3272         -                    vsFrameworkVersionMap.Add(new Version(10, 0),
         3426  +                    vsList.FrameworkVersions.Add(new Version(10, 0),
  3273   3427                           new VersionList(new Version[] {
  3274   3428                               new Version(2, 0, 50727),
  3275   3429                                   new Version(4, 0, 30319) }));
  3276   3430               }
  3277   3431           }
  3278   3432   
  3279   3433           ///////////////////////////////////////////////////////////////////////
  3280   3434   
  3281         -        private static void ResetAllVsVersions()
  3282         -        {
  3283         -            if (vsVersionList != null)
  3284         -            {
  3285         -                vsVersionList.Clear();
  3286         -                vsVersionList = null;
  3287         -            }
  3288         -        }
  3289         -
  3290         -        ///////////////////////////////////////////////////////////////////////
  3291         -
  3292         -        private static void InitializeAllVsVersions(
  3293         -            Configuration configuration
  3294         -            )
  3295         -        {
  3296         -            if (vsVersionList == null)
  3297         -            {
  3298         -                vsVersionList = new VersionList();
  3299         -
  3300         -                // vsVersionList.Add(new Version(8, 0)); // Visual Studio 2005
  3301         -
  3302         -                if ((configuration == null) || !configuration.NoVs2008)
  3303         -                    vsVersionList.Add(new Version(9, 0)); // Visual Studio 2008
  3304         -
  3305         -                if ((configuration == null) || !configuration.NoVs2010)
  3306         -                    vsVersionList.Add(new Version(10, 0));// Visual Studio 2010
         3435  +        private static void InitializeVsPackage(
         3436  +            ref Package package
         3437  +            )
         3438  +        {
         3439  +            if (package == null)
         3440  +            {
         3441  +                package = new Package();
         3442  +
         3443  +                package.AdoNetTechnologyId = new Guid(
         3444  +                    "77AB9A9D-78B9-4BA7-91AC-873F5338F1D2");
         3445  +
         3446  +                package.PackageId = new Guid(
         3447  +                    "DCBE6C8D-0E57-4099-A183-98FF74C64D9C");
         3448  +
         3449  +                package.ServiceId = new Guid(
         3450  +                    "DCBE6C8D-0E57-4099-A183-98FF74C64D9D");
         3451  +
         3452  +                package.DataSourceId = new Guid(
         3453  +                    "0EBAAB6E-CA80-4B4A-8DDF-CBE6BF058C71");
         3454  +
         3455  +                package.DataProviderId = new Guid(
         3456  +                    "0EBAAB6E-CA80-4B4A-8DDF-CBE6BF058C70");
  3307   3457               }
  3308   3458           }
  3309   3459   
  3310   3460           ///////////////////////////////////////////////////////////////////////
  3311   3461   
  3312   3462           private static bool HaveVsVersion(
  3313   3463               RegistryKey rootKey,
  3314   3464               Version vsVersion,
  3315   3465               bool whatIf,
  3316   3466               bool verbose
  3317   3467               )
  3318   3468           {
         3469  +            if (vsVersion == null)
         3470  +                return false;
         3471  +
  3319   3472               string format = "Software\\Microsoft\\VisualStudio\\{0}";
  3320   3473               string keyName = String.Format(format, vsVersion);
  3321   3474   
  3322   3475               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  3323   3476                       rootKey, keyName, false, whatIf, verbose))
  3324   3477               {
  3325   3478                   if (key == null)
................................................................................
  3342   3495                   return true;
  3343   3496               }
  3344   3497           }
  3345   3498   
  3346   3499           ///////////////////////////////////////////////////////////////////////
  3347   3500   
  3348   3501           private static bool ForEachVsVersionRegistry(
         3502  +            VsList vsList,
  3349   3503               VisualStudioRegistryCallback callback,
  3350         -            Guid packageId,
  3351         -            Guid serviceId,
  3352         -            Guid dataSourceId,
  3353         -            Guid dataProviderId,
         3504  +            Package package,
  3354   3505               object clientData,
  3355   3506               bool whatIf,
  3356   3507               bool verbose,
  3357   3508               ref string error
  3358   3509               )
  3359   3510           {
  3360         -            RegistryKey rootKey = vsRootKey;
         3511  +            if (vsList == null)
         3512  +            {
         3513  +                error = "invalid VS list";
         3514  +                return false;
         3515  +            }
         3516  +
         3517  +            RegistryKey rootKey = vsList.RootKey;
  3361   3518   
  3362   3519               if (rootKey == null)
  3363   3520               {
  3364   3521                   error = "invalid root key";
  3365   3522                   return false;
  3366   3523               }
  3367   3524   
................................................................................
  3368   3525               if (!Object.ReferenceEquals(rootKey, Registry.CurrentUser) &&
  3369   3526                   !Object.ReferenceEquals(rootKey, Registry.LocalMachine))
  3370   3527               {
  3371   3528                   error = "root key must be per-user or per-machine";
  3372   3529                   return false;
  3373   3530               }
  3374   3531   
  3375         -            if (vsVersionList == null)
         3532  +            if (vsList.Versions == null)
  3376   3533               {
  3377   3534                   error = "no VS versions found";
  3378   3535                   return false;
  3379   3536               }
  3380   3537   
  3381         -            foreach (Version vsVersion in vsVersionList)
         3538  +            foreach (Version vsVersion in vsList.Versions)
  3382   3539               {
  3383   3540                   TraceOps.Trace(
  3384   3541                       TracePriority.Lower, traceCallback, String.Format(
  3385   3542                       "vsVersion = {0}", ForDisplay(vsVersion)),
  3386   3543                       traceCategory);
  3387   3544   
  3388   3545                   if (!HaveVsVersion(rootKey, vsVersion, whatIf, verbose))
................................................................................
  3394   3551                       continue;
  3395   3552                   }
  3396   3553   
  3397   3554                   if (callback == null)
  3398   3555                       continue;
  3399   3556   
  3400   3557                   if (!callback(
  3401         -                        rootKey, vsVersion, packageId, serviceId,
  3402         -                        dataSourceId, dataProviderId, clientData, whatIf,
         3558  +                        rootKey, vsVersion, package, clientData, whatIf,
  3403   3559                           verbose, ref error))
  3404   3560                   {
  3405   3561                       return false;
  3406   3562                   }
  3407   3563               }
  3408   3564   
  3409   3565               return true;
................................................................................
  3751   3907           ///////////////////////////////////////////////////////////////////////
  3752   3908   
  3753   3909           #region Visual Studio Handling
  3754   3910           private static string GetVsKeyName(
  3755   3911               Version vsVersion
  3756   3912               )
  3757   3913           {
         3914  +            if (vsVersion == null)
         3915  +                return null;
         3916  +
  3758   3917               return String.Format("Software\\Microsoft\\VisualStudio\\{0}",
  3759   3918                   vsVersion);
  3760   3919           }
  3761   3920   
  3762   3921           ///////////////////////////////////////////////////////////////////////
  3763   3922   
  3764   3923           #region Visual Studio Version Handling
  3765   3924           private static bool AddVsVersion(
  3766   3925               RegistryKey rootKey,
  3767   3926               Version vsVersion,
  3768         -            Guid packageId,
  3769         -            Guid serviceId,
  3770         -            Guid dataSourceId,
  3771         -            Guid dataProviderId,
         3927  +            Package package,
  3772   3928               object clientData,
  3773   3929               bool whatIf,
  3774   3930               bool verbose,
  3775   3931               ref string error
  3776   3932               )
  3777   3933           {
  3778         -            VersionList versionList = clientData as VersionList;
         3934  +            if (vsVersion != null)
         3935  +            {
         3936  +                VsList vsList = clientData as VsList;
  3779   3937   
  3780         -            if (versionList != null)
  3781         -                versionList.Add(vsVersion);
         3938  +                if (vsList != null)
         3939  +                {
         3940  +                    if (vsList.InstalledVersions == null)
         3941  +                        vsList.InstalledVersions = new VersionList();
         3942  +
         3943  +                    if (!vsList.InstalledVersions.Contains(vsVersion))
         3944  +                        vsList.InstalledVersions.Add(vsVersion);
         3945  +                }
         3946  +            }
  3782   3947   
  3783   3948               return true;
  3784   3949           }
  3785   3950           #endregion
  3786   3951   
  3787   3952           ///////////////////////////////////////////////////////////////////////
  3788   3953   
  3789   3954           #region Visual Studio Data Source Handling
  3790   3955           private static bool AddVsDataSource(
  3791   3956               RegistryKey rootKey,
  3792   3957               Version vsVersion,
  3793         -            Guid dataSourceId,
  3794         -            Guid dataProviderId,
         3958  +            Package package,
  3795   3959               bool whatIf,
  3796   3960               bool verbose,
  3797   3961               ref string error
  3798   3962               )
  3799   3963           {
         3964  +            if (vsVersion == null)
         3965  +            {
         3966  +                error = "invalid VS version";
         3967  +                return false;
         3968  +            }
         3969  +
         3970  +            if (package == null)
         3971  +            {
         3972  +                error = "invalid VS package";
         3973  +                return false;
         3974  +            }
         3975  +
  3800   3976               string keyName = GetVsKeyName(vsVersion);
  3801   3977   
  3802   3978               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  3803   3979                       rootKey, keyName, false, whatIf, verbose))
  3804   3980               {
  3805   3981                   if (key == null)
  3806   3982                   {
................................................................................
  3819   3995                           error = String.Format(
  3820   3996                               "could not open registry key: {0}\\DataSources",
  3821   3997                               key);
  3822   3998   
  3823   3999                           return false;
  3824   4000                       }
  3825   4001   
  3826         -                    using (MockRegistryKey dataSourceKey = RegistryHelper.CreateSubKey(
  3827         -                            subKey, dataSourceId.ToString(VsIdFormat), whatIf,
  3828         -                            verbose))
         4002  +                    using (MockRegistryKey dataSourceKey =
         4003  +                            RegistryHelper.CreateSubKey(subKey,
         4004  +                            package.DataSourceId.ToString(VsIdFormat),
         4005  +                            whatIf, verbose))
  3829   4006                       {
  3830   4007                           if (dataSourceKey == null)
  3831   4008                           {
  3832   4009                               error = String.Format(
  3833         -                                "could not create registry key: {0}\\{1}",
  3834         -                                key, dataSourceId.ToString(VsIdFormat));
         4010  +                                "could not create registry key: {0}\\{1}", key,
         4011  +                                package.DataSourceId.ToString(VsIdFormat));
  3835   4012   
  3836   4013                               return false;
  3837   4014                           }
  3838   4015   
  3839   4016                           RegistryHelper.SetValue(
  3840   4017                               dataSourceKey, null, String.Format(
  3841   4018                               "{0} Database File", ProjectName), whatIf,
  3842   4019                               verbose);
  3843   4020   
  3844   4021                           RegistryHelper.CreateSubKey(dataSourceKey,
  3845   4022                               String.Format("SupportingProviders\\{0}",
  3846         -                            dataProviderId.ToString(VsIdFormat)), whatIf,
  3847         -                            verbose);
         4023  +                            package.DataProviderId.ToString(VsIdFormat)),
         4024  +                            whatIf, verbose);
  3848   4025                       }
  3849   4026                   }
  3850   4027               }
  3851   4028   
  3852   4029               return true;
  3853   4030           }
  3854   4031   
  3855   4032           ///////////////////////////////////////////////////////////////////////
  3856   4033   
  3857   4034           private static bool RemoveVsDataSource(
  3858   4035               RegistryKey rootKey,
  3859   4036               Version vsVersion,
  3860         -            Guid dataSourceId,
         4037  +            Package package,
  3861   4038               bool whatIf,
  3862   4039               bool verbose,
  3863   4040               ref string error
  3864   4041               )
  3865   4042           {
         4043  +            if (vsVersion == null)
         4044  +            {
         4045  +                error = "invalid VS version";
         4046  +                return false;
         4047  +            }
         4048  +
         4049  +            if (package == null)
         4050  +            {
         4051  +                error = "invalid VS package";
         4052  +                return false;
         4053  +            }
         4054  +
  3866   4055               string keyName = GetVsKeyName(vsVersion);
  3867   4056   
  3868   4057               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  3869   4058                       rootKey, keyName, false, whatIf, verbose))
  3870   4059               {
  3871   4060                   if (key == null)
  3872   4061                   {
................................................................................
  3886   4075                               "could not open registry key: {0}\\DataSources",
  3887   4076                               key);
  3888   4077   
  3889   4078                           return false;
  3890   4079                       }
  3891   4080   
  3892   4081                       RegistryHelper.DeleteSubKeyTree(
  3893         -                        subKey, dataSourceId.ToString(VsIdFormat), whatIf,
  3894         -                        verbose);
         4082  +                        subKey, package.DataSourceId.ToString(VsIdFormat),
         4083  +                        whatIf, verbose);
  3895   4084                   }
  3896   4085               }
  3897   4086   
  3898   4087               return true;
  3899   4088           }
  3900   4089   
  3901   4090           ///////////////////////////////////////////////////////////////////////
  3902   4091   
  3903   4092           private static bool ProcessVsDataSource(
  3904   4093               RegistryKey rootKey,
  3905   4094               Version vsVersion,
  3906         -            Guid packageId, /* NOT USED */
  3907         -            Guid serviceId, /* NOT USED */
  3908         -            Guid dataSourceId,
  3909         -            Guid dataProviderId,
         4095  +            Package package,
  3910   4096               object clientData,
  3911   4097               bool whatIf,
  3912   4098               bool verbose,
  3913   4099               ref string error
  3914   4100               )
  3915   4101           {
         4102  +            if (package == null)
         4103  +            {
         4104  +                error = "invalid VS package";
         4105  +                return false;
         4106  +            }
         4107  +
  3916   4108               AnyPair<string, bool> pair = clientData as AnyPair<string, bool>;
  3917   4109   
  3918   4110               if (pair == null)
  3919   4111               {
  3920   4112                   error = "invalid VS callback data";
  3921   4113                   return false;
  3922   4114               }
  3923   4115   
  3924   4116               if (pair.Y)
  3925   4117               {
  3926   4118                   return AddVsDataSource(
  3927         -                    rootKey, vsVersion, dataSourceId, dataProviderId,
  3928         -                    whatIf, verbose, ref error);
         4119  +                    rootKey, vsVersion, package, whatIf, verbose, ref error);
  3929   4120               }
  3930   4121               else
  3931   4122               {
  3932   4123                   return RemoveVsDataSource(
  3933         -                    rootKey, vsVersion, dataSourceId, whatIf, verbose,
  3934         -                    ref error);
         4124  +                    rootKey, vsVersion, package, whatIf, verbose, ref error);
  3935   4125               }
  3936   4126           }
  3937   4127           #endregion
  3938   4128   
  3939   4129           ///////////////////////////////////////////////////////////////////////
  3940   4130   
  3941   4131           #region Visual Studio Data Provider Handling
  3942   4132           private static bool AddVsDataProvider(
  3943   4133               RegistryKey rootKey,
  3944   4134               Version vsVersion,
  3945         -            Guid serviceId,
  3946         -            Guid dataProviderId,
         4135  +            Package package,
  3947   4136               string fileName,
  3948   4137               bool whatIf,
  3949   4138               bool verbose,
  3950   4139               ref string error
  3951   4140               )
  3952   4141           {
  3953         -            if (vsAdoNetTechnologyId == null)
         4142  +            if (vsVersion == null)
  3954   4143               {
  3955         -                error = "invalid ADO.NET technology Id";
         4144  +                error = "invalid VS version";
         4145  +                return false;
         4146  +            }
         4147  +
         4148  +            if (package == null)
         4149  +            {
         4150  +                error = "invalid VS package";
  3956   4151                   return false;
  3957   4152               }
  3958   4153   
  3959   4154               string keyName = GetVsKeyName(vsVersion);
  3960   4155   
  3961   4156               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  3962   4157                       rootKey, keyName, false, whatIf, verbose))
................................................................................
  3978   4173                           error = String.Format(
  3979   4174                               "could not open registry key: {0}\\DataProviders",
  3980   4175                               key);
  3981   4176   
  3982   4177                           return false;
  3983   4178                       }
  3984   4179   
  3985         -                    using (MockRegistryKey dataProviderKey = RegistryHelper.CreateSubKey(
  3986         -                            subKey, dataProviderId.ToString(VsIdFormat), whatIf,
  3987         -                            verbose))
         4180  +                    using (MockRegistryKey dataProviderKey =
         4181  +                            RegistryHelper.CreateSubKey(subKey,
         4182  +                            package.DataProviderId.ToString(VsIdFormat),
         4183  +                            whatIf, verbose))
  3988   4184                       {
  3989   4185                           if (dataProviderKey == null)
  3990   4186                           {
  3991   4187                               error = String.Format(
  3992         -                                "could not create registry key: {0}\\{1}",
  3993         -                                key, dataProviderId.ToString(VsIdFormat));
         4188  +                                "could not create registry key: {0}\\{1}", key,
         4189  +                                package.DataProviderId.ToString(VsIdFormat));
  3994   4190   
  3995   4191                               return false;
  3996   4192                           }
  3997   4193   
  3998   4194                           RegistryHelper.SetValue(
  3999   4195                               dataProviderKey, null, Description, whatIf,
  4000   4196                               verbose);
................................................................................
  4001   4197   
  4002   4198                           RegistryHelper.SetValue(
  4003   4199                               dataProviderKey, "InvariantName", InvariantName,
  4004   4200                               whatIf, verbose);
  4005   4201   
  4006   4202                           RegistryHelper.SetValue(
  4007   4203                               dataProviderKey, "Technology",
  4008         -                            ((Guid)vsAdoNetTechnologyId).ToString(VsIdFormat),
         4204  +                            package.AdoNetTechnologyId.ToString(VsIdFormat),
  4009   4205                               whatIf, verbose);
  4010   4206   
  4011   4207                           RegistryHelper.SetValue(
  4012   4208                               dataProviderKey, "CodeBase", fileName, whatIf,
  4013   4209                               verbose);
  4014   4210   
  4015   4211                           RegistryHelper.SetValue(
  4016   4212                               dataProviderKey, "FactoryService",
  4017         -                            serviceId.ToString(VsIdFormat), whatIf, verbose);
         4213  +                            package.ServiceId.ToString(VsIdFormat), whatIf,
         4214  +                            verbose);
  4018   4215   
  4019   4216                           RegistryHelper.CreateSubKey(dataProviderKey,
  4020   4217                               "SupportedObjects\\DataConnectionUIControl",
  4021   4218                               whatIf, verbose);
  4022   4219   
  4023   4220                           RegistryHelper.CreateSubKey(dataProviderKey,
  4024   4221                               "SupportedObjects\\DataConnectionProperties",
................................................................................
  4043   4240           }
  4044   4241   
  4045   4242           ///////////////////////////////////////////////////////////////////////
  4046   4243   
  4047   4244           private static bool RemoveVsDataProvider(
  4048   4245               RegistryKey rootKey,
  4049   4246               Version vsVersion,
  4050         -            Guid dataProviderId,
         4247  +            Package package,
  4051   4248               bool whatIf,
  4052   4249               bool verbose,
  4053   4250               ref string error
  4054   4251               )
  4055   4252           {
         4253  +            if (vsVersion == null)
         4254  +            {
         4255  +                error = "invalid VS version";
         4256  +                return false;
         4257  +            }
         4258  +
  4056   4259               string keyName = GetVsKeyName(vsVersion);
  4057   4260   
  4058   4261               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  4059   4262                       rootKey, keyName, false, whatIf, verbose))
  4060   4263               {
  4061   4264                   if (key == null)
  4062   4265                   {
................................................................................
  4076   4279                               "could not open registry key: {0}\\DataProviders",
  4077   4280                               key);
  4078   4281   
  4079   4282                           return false;
  4080   4283                       }
  4081   4284   
  4082   4285                       RegistryHelper.DeleteSubKeyTree(
  4083         -                        subKey, dataProviderId.ToString(VsIdFormat), whatIf,
  4084         -                        verbose);
         4286  +                        subKey, package.DataProviderId.ToString(VsIdFormat),
         4287  +                        whatIf, verbose);
  4085   4288                   }
  4086   4289               }
  4087   4290   
  4088   4291               return true;
  4089   4292           }
  4090   4293   
  4091   4294           ///////////////////////////////////////////////////////////////////////
  4092   4295   
  4093   4296           private static bool ProcessVsDataProvider(
  4094   4297               RegistryKey rootKey,
  4095   4298               Version vsVersion,
  4096         -            Guid packageId, /* NOT USED */
  4097         -            Guid serviceId,
  4098         -            Guid dataSourceId, /* NOT USED */
  4099         -            Guid dataProviderId,
         4299  +            Package package,
  4100   4300               object clientData,
  4101   4301               bool whatIf,
  4102   4302               bool verbose,
  4103   4303               ref string error
  4104   4304               )
  4105   4305           {
  4106   4306               AnyPair<string, bool> pair = clientData as AnyPair<string, bool>;
................................................................................
  4110   4310                   error = "invalid VS callback data";
  4111   4311                   return false;
  4112   4312               }
  4113   4313   
  4114   4314               if (pair.Y)
  4115   4315               {
  4116   4316                   return AddVsDataProvider(
  4117         -                    rootKey, vsVersion, serviceId, dataProviderId, pair.X,
         4317  +                    rootKey, vsVersion, package, pair.X,
  4118   4318                       whatIf, verbose, ref error);
  4119   4319               }
  4120   4320               else
  4121   4321               {
  4122   4322                   return RemoveVsDataProvider(
  4123         -                    rootKey, vsVersion, dataProviderId, whatIf, verbose,
  4124         -                    ref error);
         4323  +                    rootKey, vsVersion, package, whatIf,
         4324  +                    verbose, ref error);
  4125   4325               }
  4126   4326           }
  4127   4327           #endregion
  4128   4328   
  4129   4329           ///////////////////////////////////////////////////////////////////////
  4130   4330   
  4131   4331           #region Visual Studio Package Handling
  4132   4332           private static bool AddVsPackage(
  4133   4333               RegistryKey rootKey,
  4134   4334               Version vsVersion,
  4135         -            Guid packageId,
  4136         -            Guid serviceId,
         4335  +            Package package,
  4137   4336               string fileName,
  4138   4337               bool whatIf,
  4139   4338               bool verbose,
  4140   4339               ref string error
  4141   4340               )
  4142   4341           {
         4342  +            if (vsVersion == null)
         4343  +            {
         4344  +                error = "invalid VS version";
         4345  +                return false;
         4346  +            }
         4347  +
         4348  +            if (package == null)
         4349  +            {
         4350  +                error = "invalid VS package";
         4351  +                return false;
         4352  +            }
         4353  +
  4143   4354               string keyName = GetVsKeyName(vsVersion);
  4144   4355   
  4145   4356               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  4146   4357                       rootKey, keyName, false, whatIf, verbose))
  4147   4358               {
  4148   4359                   if (key == null)
  4149   4360                   {
................................................................................
  4163   4374                               "could not open registry key: {0}\\Packages",
  4164   4375                               key);
  4165   4376   
  4166   4377                           return false;
  4167   4378                       }
  4168   4379   
  4169   4380                       using (MockRegistryKey packageKey = RegistryHelper.CreateSubKey(
  4170         -                            subKey, packageId.ToString(VsIdFormat), whatIf,
         4381  +                            subKey, package.PackageId.ToString(VsIdFormat), whatIf,
  4171   4382                               verbose))
  4172   4383                       {
  4173   4384                           if (packageKey == null)
  4174   4385                           {
  4175   4386                               error = String.Format(
  4176   4387                                   "could not create registry key: {0}\\{1}",
  4177         -                                key, packageId.ToString(VsIdFormat));
         4388  +                                key, package.PackageId.ToString(VsIdFormat));
  4178   4389   
  4179   4390                               return false;
  4180   4391                           }
  4181   4392   
  4182   4393                           RegistryHelper.SetValue(packageKey, null, String.Format(
  4183   4394                               "{0} Designer Package", ProjectName), whatIf,
  4184   4395                               verbose);
................................................................................
  4237   4448                               "could not open registry key: {0}\\Menus",
  4238   4449                               key);
  4239   4450   
  4240   4451                           return false;
  4241   4452                       }
  4242   4453   
  4243   4454                       RegistryHelper.SetValue(
  4244         -                        subKey, packageId.ToString(VsIdFormat), ", 1000, 3",
  4245         -                        whatIf, verbose);
         4455  +                        subKey, package.PackageId.ToString(VsIdFormat),
         4456  +                        ", 1000, 3", whatIf, verbose);
  4246   4457                   }
  4247   4458   
  4248   4459                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  4249   4460                           key, "Services", true, whatIf, verbose))
  4250   4461                   {
  4251   4462                       if (subKey == null)
  4252   4463                       {
................................................................................
  4254   4465                               "could not open registry key: {0}\\Services",
  4255   4466                               key);
  4256   4467   
  4257   4468                           return false;
  4258   4469                       }
  4259   4470   
  4260   4471                       using (MockRegistryKey serviceKey = RegistryHelper.CreateSubKey(
  4261         -                            subKey, serviceId.ToString(VsIdFormat), whatIf,
         4472  +                            subKey, package.ServiceId.ToString(VsIdFormat), whatIf,
  4262   4473                               verbose))
  4263   4474                       {
  4264   4475                           if (serviceKey == null)
  4265   4476                           {
  4266   4477                               error = String.Format(
  4267   4478                                   "could not create registry key: {0}\\{1}",
  4268         -                                key, serviceId.ToString(VsIdFormat));
         4479  +                                key, package.ServiceId.ToString(VsIdFormat));
  4269   4480   
  4270   4481                               return false;
  4271   4482                           }
  4272   4483   
  4273   4484                           RegistryHelper.SetValue(serviceKey, null,
  4274         -                            packageId.ToString(VsIdFormat), whatIf, verbose);
         4485  +                            package.PackageId.ToString(VsIdFormat), whatIf,
         4486  +                            verbose);
  4275   4487   
  4276   4488                           RegistryHelper.SetValue(serviceKey, "Name",
  4277   4489                               String.Format("{0} Designer Service", ProjectName),
  4278   4490                               whatIf, verbose);
  4279   4491                       }
  4280   4492                   }
  4281   4493               }
................................................................................
  4284   4496           }
  4285   4497   
  4286   4498           ///////////////////////////////////////////////////////////////////////
  4287   4499   
  4288   4500           private static bool RemoveVsPackage(
  4289   4501               RegistryKey rootKey,
  4290   4502               Version vsVersion,
  4291         -            Guid packageId,
  4292         -            Guid serviceId,
         4503  +            Package package,
  4293   4504               bool whatIf,
  4294   4505               bool verbose,
  4295   4506               ref string error
  4296   4507               )
  4297   4508           {
         4509  +            if (vsVersion == null)
         4510  +            {
         4511  +                error = "invalid VS version";
         4512  +                return false;
         4513  +            }
         4514  +
         4515  +            if (package == null)
         4516  +            {
         4517  +                error = "invalid VS package";
         4518  +                return false;
         4519  +            }
         4520  +
  4298   4521               string keyName = GetVsKeyName(vsVersion);
  4299   4522   
  4300   4523               using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  4301   4524                       rootKey, keyName, false, whatIf, verbose))
  4302   4525               {
  4303   4526                   if (key == null)
  4304   4527                   {
................................................................................
  4318   4541                               "could not open registry key: {0}\\Packages",
  4319   4542                               key);
  4320   4543   
  4321   4544                           return false;
  4322   4545                       }
  4323   4546   
  4324   4547                       RegistryHelper.DeleteSubKeyTree(
  4325         -                        key, packageId.ToString(VsIdFormat), whatIf, verbose);
         4548  +                        key, package.PackageId.ToString(VsIdFormat), whatIf,
         4549  +                        verbose);
  4326   4550                   }
  4327   4551   
  4328   4552                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  4329   4553                           key, "Menus", true, whatIf, verbose))
  4330   4554                   {
  4331   4555                       if (subKey == null)
  4332   4556                       {
................................................................................
  4334   4558                               "could not open registry key: {0}\\Menus",
  4335   4559                               key);
  4336   4560   
  4337   4561                           return false;
  4338   4562                       }
  4339   4563   
  4340   4564                       RegistryHelper.DeleteValue(
  4341         -                        subKey, packageId.ToString(VsIdFormat), whatIf,
         4565  +                        subKey, package.PackageId.ToString(VsIdFormat), whatIf,
  4342   4566                           verbose);
  4343   4567                   }
  4344   4568   
  4345   4569                   using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  4346   4570                           key, "Services", true, whatIf, verbose))
  4347   4571                   {
  4348   4572                       if (subKey == null)
................................................................................
  4351   4575                               "could not open registry key: {0}\\Services",
  4352   4576                               key);
  4353   4577   
  4354   4578                           return false;
  4355   4579                       }
  4356   4580   
  4357   4581                       RegistryHelper.DeleteSubKeyTree(
  4358         -                        subKey, serviceId.ToString(VsIdFormat), whatIf,
         4582  +                        subKey, package.ServiceId.ToString(VsIdFormat), whatIf,
  4359   4583                           verbose);
  4360   4584                   }
  4361   4585               }
  4362   4586   
  4363   4587               return true;
  4364   4588           }
  4365   4589   
  4366   4590           ///////////////////////////////////////////////////////////////////////
  4367   4591   
  4368   4592           private static bool ProcessVsPackage(
  4369   4593               RegistryKey rootKey,
  4370   4594               Version vsVersion,
  4371         -            Guid packageId,
  4372         -            Guid serviceId,
  4373         -            Guid dataSourceId,
  4374         -            Guid dataProviderId,
         4595  +            Package package,
  4375   4596               object clientData,
  4376   4597               bool whatIf,
  4377   4598               bool verbose,
  4378   4599               ref string error
  4379   4600               )
  4380   4601           {
  4381   4602               AnyPair<string, bool> pair = clientData as AnyPair<string, bool>;
................................................................................
  4385   4606                   error = "invalid VS callback data";
  4386   4607                   return false;
  4387   4608               }
  4388   4609   
  4389   4610               if (pair.Y)
  4390   4611               {
  4391   4612                   return AddVsPackage(
  4392         -                    rootKey, vsVersion, packageId, serviceId, pair.X, whatIf,
         4613  +                    rootKey, vsVersion, package, pair.X, whatIf,
  4393   4614                       verbose, ref error);
  4394   4615               }
  4395   4616               else
  4396   4617               {
  4397   4618                   return RemoveVsPackage(
  4398         -                    rootKey, vsVersion, packageId, serviceId, whatIf, verbose,
         4619  +                    rootKey, vsVersion, package, whatIf, verbose,
  4399   4620                       ref error);
  4400   4621               }
  4401   4622           }
  4402   4623           #endregion
  4403   4624           #endregion
  4404   4625   
  4405   4626           ///////////////////////////////////////////////////////////////////////
  4406   4627   
  4407   4628           #region Application Entry Point
  4408         -        public static string GetImageRuntimeVersion(
  4409         -            string fileName
  4410         -            )
  4411         -        {
  4412         -            try
  4413         -            {
  4414         -                Assembly assembly =
  4415         -                    Assembly.ReflectionOnlyLoadFrom(fileName); /* throw */
  4416         -
  4417         -                if (assembly != null)
  4418         -                    return assembly.ImageRuntimeVersion;
  4419         -            }
  4420         -            catch
  4421         -            {
  4422         -                // do nothing.
  4423         -            }
  4424         -
  4425         -            return null;
  4426         -        }
  4427         -
  4428         -        ///////////////////////////////////////////////////////////////////////
  4429         -
  4430   4629           private static int Main(
  4431   4630               string[] args
  4432   4631               )
  4433   4632           {
         4633  +            Package package = null;
         4634  +            FrameworkList frameworkList = null;
         4635  +            VsList vsList = null;
  4434   4636               Configuration configuration = null;
  4435   4637               string error = null;
  4436   4638   
  4437   4639               ///////////////////////////////////////////////////////////////////
  4438   4640   
  4439   4641               #region Command Line Processing
  4440   4642               if (!Configuration.FromArgs(
................................................................................
  4445   4647                   TraceOps.ShowMessage(
  4446   4648                       TracePriority.Highest, traceCallback, thisAssembly,
  4447   4649                       error, traceCategory, MessageBoxButtons.OK,
  4448   4650                       MessageBoxIcon.Error);
  4449   4651   
  4450   4652                   return 1; /* FAILURE */
  4451   4653               }
         4654  +
         4655  +            ///////////////////////////////////////////////////////////////////
         4656  +
         4657  +            InitializeVsPackage(ref package);
         4658  +            InitializeFrameworkList(configuration, ref frameworkList);
         4659  +            InitializeVsList(configuration, ref vsList);
  4452   4660               #endregion
  4453   4661   
  4454   4662               ///////////////////////////////////////////////////////////////////
  4455   4663   
         4664  +#if false
  4456   4665               #region Check Installed VS Versions
  4457         -            InitializeVsRootKeyAndIds();
  4458         -            InitializeAllFrameworks(null);
  4459         -            InitializeAllVsVersions(null);
  4460         -
  4461         -            VersionList installedVsVersions = new VersionList();
  4462         -
  4463   4666               if (configuration.HasFlags(InstallFlags.All, /* any */ false))
  4464   4667               {
  4465         -                if (!ForEachVsVersionRegistry(AddVsVersion,
  4466         -                        Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty,
  4467         -                        installedVsVersions, configuration.WhatIf,
  4468         -                        configuration.Verbose, ref error))
         4668  +                if (!ForEachVsVersionRegistry(
         4669  +                        vsList, AddVsVersion, null, vsList,
         4670  +                        configuration.WhatIf, configuration.Verbose,
         4671  +                        ref error))
         4672  +                {
         4673  +                    TraceOps.ShowMessage(
         4674  +                        TracePriority.Highest, traceCallback, null,
         4675  +                        error, traceCategory, MessageBoxButtons.OK,
         4676  +                        MessageBoxIcon.Error);
         4677  +
         4678  +                    return 1; /* FAILURE */
         4679  +                }
         4680  +
         4681  +                if (!Configuration.CheckImageRuntimeVersion(
         4682  +                        configuration, vsList, true, ref error))
  4469   4683                   {
  4470   4684                       TraceOps.ShowMessage(
  4471   4685                           TracePriority.Highest, traceCallback, null,
  4472   4686                           error, traceCategory, MessageBoxButtons.OK,
  4473   4687                           MessageBoxIcon.Error);
  4474   4688   
  4475   4689                       return 1; /* FAILURE */
  4476   4690                   }
  4477   4691               }
  4478         -
  4479         -            InitializeVsFrameworkVersionMap(configuration);
  4480         -
  4481         -            ///////////////////////////////////////////////////////////////////
  4482         -
  4483         -            if (!Configuration.CheckImageRuntimeVersion(
  4484         -                    configuration, vsFrameworkVersionMap,
  4485         -                    installedVsVersions, true, ref error))
  4486         -            {
  4487         -                TraceOps.ShowMessage(
  4488         -                    TracePriority.Highest, traceCallback, thisAssembly,
  4489         -                    error, traceCategory, MessageBoxButtons.OK,
  4490         -                    MessageBoxIcon.Error);
  4491         -
  4492         -                return 1; /* FAILURE */
  4493         -            }
  4494         -
  4495         -            ///////////////////////////////////////////////////////////////////
  4496         -
  4497         -            InitializeAllFrameworks(configuration);
  4498         -            InitializeAllVsVersions(configuration);
  4499   4692               #endregion
         4693  +#endif
  4500   4694   
  4501   4695               ///////////////////////////////////////////////////////////////////
  4502   4696   
  4503   4697               AssemblyName assemblyName = AssemblyName.GetAssemblyName(
  4504   4698                   configuration.CoreFileName); /* throw */
  4505   4699   
  4506   4700               ///////////////////////////////////////////////////////////////////
................................................................................
  4561   4755               #endregion
  4562   4756   
  4563   4757               ///////////////////////////////////////////////////////////////////
  4564   4758   
  4565   4759               #region .NET AssemblyFolders
  4566   4760               if (configuration.HasFlags(InstallFlags.AssemblyFolders, true))
  4567   4761               {
  4568         -                if (!ForEachFrameworkRegistry(ProcessAssemblyFolders,
         4762  +                if (!ForEachFrameworkRegistry(
         4763  +                        frameworkList, ProcessAssemblyFolders,
  4569   4764                           directoryPair, configuration.WhatIf,
  4570   4765                           configuration.Verbose, ref error))
  4571   4766                   {
  4572   4767                       TraceOps.ShowMessage(
  4573   4768                           TracePriority.Highest, traceCallback, null,
  4574   4769                           error, traceCategory, MessageBoxButtons.OK,
  4575   4770                           MessageBoxIcon.Error);
................................................................................
  4582   4777               ///////////////////////////////////////////////////////////////////
  4583   4778   
  4584   4779               #region .NET DbProviderFactory
  4585   4780               if (configuration.HasFlags(InstallFlags.DbProviderFactory, true))
  4586   4781               {
  4587   4782                   bool saved = false;
  4588   4783   
  4589         -                if (!ForEachFrameworkConfig(ProcessDbProviderFactory,
         4784  +                if (!ForEachFrameworkConfig(
         4785  +                        frameworkList, ProcessDbProviderFactory,
  4590   4786                           InvariantName, ProviderName, Description,
  4591   4787                           FactoryTypeName, assemblyName, directoryPair,
  4592   4788                           configuration.WhatIf, configuration.Verbose,
  4593   4789                           ref saved, ref error))
  4594   4790                   {
  4595   4791                       TraceOps.ShowMessage(
  4596   4792                           TracePriority.Highest, traceCallback, null,
................................................................................
  4603   4799               #endregion
  4604   4800   
  4605   4801               ///////////////////////////////////////////////////////////////////
  4606   4802   
  4607   4803               #region VS Package
  4608   4804               if (configuration.HasFlags(InstallFlags.VsPackage, true))
  4609   4805               {
  4610         -                if (!ForEachVsVersionRegistry(ProcessVsPackage,
  4611         -                        (Guid)vsPackageId, (Guid)vsServiceId,
  4612         -                        (Guid)vsDataSourcesId, (Guid)vsDataProviderId,
  4613         -                        fileNamePair, configuration.WhatIf,
  4614         -                        configuration.Verbose, ref error))
         4806  +                if (!ForEachVsVersionRegistry(
         4807  +                        vsList, ProcessVsPackage, package, fileNamePair,
         4808  +                        configuration.WhatIf, configuration.Verbose,
         4809  +                        ref error))
  4615   4810                   {
  4616   4811                       TraceOps.ShowMessage(
  4617   4812                           TracePriority.Highest, traceCallback, null,
  4618   4813                           error, traceCategory, MessageBoxButtons.OK,
  4619   4814                           MessageBoxIcon.Error);
  4620   4815   
  4621   4816                       return 1; /* FAILURE */
................................................................................
  4624   4819               #endregion
  4625   4820   
  4626   4821               ///////////////////////////////////////////////////////////////////
  4627   4822   
  4628   4823               #region VS DataSource
  4629   4824               if (configuration.HasFlags(InstallFlags.VsDataSource, true))
  4630   4825               {
  4631         -                if (!ForEachVsVersionRegistry(ProcessVsDataSource,
  4632         -                        (Guid)vsPackageId, (Guid)vsServiceId,
  4633         -                        (Guid)vsDataSourcesId, (Guid)vsDataProviderId,
  4634         -                        fileNamePair, configuration.WhatIf,
  4635         -                        configuration.Verbose, ref error))
         4826  +                if (!ForEachVsVersionRegistry(
         4827  +                        vsList, ProcessVsDataSource, package, fileNamePair,
         4828  +                        configuration.WhatIf, configuration.Verbose,
         4829  +                        ref error))
  4636   4830                   {
  4637   4831                       TraceOps.ShowMessage(
  4638   4832                           TracePriority.Highest, traceCallback, null,
  4639   4833                           error, traceCategory, MessageBoxButtons.OK,
  4640   4834                           MessageBoxIcon.Error);
  4641   4835   
  4642   4836                       return 1; /* FAILURE */
................................................................................
  4645   4839               #endregion
  4646   4840   
  4647   4841               ///////////////////////////////////////////////////////////////////
  4648   4842   
  4649   4843               #region VS DataProvider
  4650   4844               if (configuration.HasFlags(InstallFlags.VsDataProvider, true))
  4651   4845               {
  4652         -                if (!ForEachVsVersionRegistry(ProcessVsDataProvider,
  4653         -                        (Guid)vsPackageId, (Guid)vsServiceId,
  4654         -                        (Guid)vsDataSourcesId, (Guid)vsDataProviderId,
  4655         -                        fileNamePair, configuration.WhatIf,
  4656         -                        configuration.Verbose, ref error))
         4846  +                if (!ForEachVsVersionRegistry(
         4847  +                        vsList, ProcessVsDataProvider, package, fileNamePair,
         4848  +                        configuration.WhatIf, configuration.Verbose,
         4849  +                        ref error))
  4657   4850                   {
  4658   4851                       TraceOps.ShowMessage(
  4659   4852                           TracePriority.Highest, traceCallback, null,
  4660   4853                           error, traceCategory, MessageBoxButtons.OK,
  4661   4854                           MessageBoxIcon.Error);
  4662   4855   
  4663   4856                       return 1; /* FAILURE */