/// <summary>
        /// Gets the Silverlight Runtime Version installed on the local machine.
        /// </summary>
        /// <param name="automationObject">Service provider.</param>
        /// <returns>
        /// A string representing a Silverlight version number.  When the full version number is
        /// found on the machine, it will be returned.  When not found, <c>null</c> will be returned.
        /// </returns>
        private static string GetSilverlightRuntimeVersion(object automationObject)
        {
            // Gets the latest version of Silverlight supported by the tools
            string silverlightToolsVersion = TemplateUtilities.GetSilverlightVersion(automationObject);

            // Open up the sub-key for the Silverlight SDK's Reference Assemblies for the specified version
            using (Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
                       string.Format(System.Globalization.CultureInfo.InvariantCulture, @"SOFTWARE\Microsoft\Microsoft SDKs\Silverlight\{0}\ReferenceAssemblies", silverlightToolsVersion)))
            {
                if (key != null)
                {
                    // Attempt to get the runtime version
                    string str = key.GetValue("SLRuntimeInstallVersion") as string;

                    if (!string.IsNullOrEmpty(str))
                    {
                        // Return it if found
                        return(str);
                    }
                }
            }

            // If we couldn't find the version in the registry, return null so the caller can
            // decide how to handle that scenario.
            return(null);
        }
コード例 #2
0
        public void RunStarted(object automationObject,
                               Dictionary <string, string> replacementsDictionary,
                               WizardRunKind runKind, object[] customParams)
        {
            this._dte2 = (DTE2)automationObject;
            this._replacementsDictionary = replacementsDictionary;
            this._replacementsDictionary["$targetsilverlightversion$"] = TemplateUtilities.GetSilverlightVersion(automationObject);
            this._dte2.Globals["safeclientprojectname"] = replacementsDictionary["$safeprojectname$"];

            // Determine whether the user has asked to add this to an existing Solution Folder.
            // We do this at startup because the active project will be changed during the creation
            // of the template.  If _activeSolutionFolder is null, it means the user did not ask
            // to create these libraries under a SolutionFolder.
            Array projects = null;

            try
            {
                projects = (Array)this._dte2.ActiveSolutionProjects;
            }
            catch (COMException)
            {
            }
            Project activeProject = projects == null ? null : projects.OfType <Project>().FirstOrDefault();

            if (activeProject != null && activeProject.Kind == ProjectKinds.vsProjectKindSolutionFolder)
            {
                this._activeSolutionFolder = activeProject.Object as SolutionFolder;
                System.Diagnostics.Debug.Assert(this._activeSolutionFolder != null, "Failed to cast dynamic oject to SolutionFolder");
            }
        }
コード例 #3
0
        public void RunStarted(object automationObject,
                               Dictionary <string, string> replacementsDictionary,
                               WizardRunKind runKind, object[] customParams)
        {
            this._dte2      = (DTE2)automationObject;
            this._solution2 = (Solution2)this._dte2.Solution;
            this._replacementsDictionary = replacementsDictionary;
            this._replacementsDictionary["$targetsilverlightversion$"] = TemplateUtilities.GetSilverlightVersion(automationObject);
            this._dte2.Globals["safeclientprojectname"] = replacementsDictionary["$safeprojectname$"];
            this._webProjectName = this._replacementsDictionary["$safeprojectname$"] + ".Web";
            this._customParams   = customParams;

            // Determine whether the user has asked to add this to an existing Solution Folder.
            // We do this at startup because the active project will be changed during the creation
            // of the template.  If _selectedSolutionFolder is null, it means the user did not ask
            // to create the business application under a SolutionFolder.
            Array projects = null;

            try
            {
                projects = (Array)this._dte2.ActiveSolutionProjects;
            }
            catch (COMException)
            {
            }
            Project activeProject = projects == null ? null : projects.OfType <Project>().FirstOrDefault();

            if (activeProject != null &&
                activeProject.Object is SolutionFolder)
            {
                this._selectedSolutionFolder = activeProject;
            }
        }