Beispiel #1
0
        /// <summary>
        /// Code factory framework calls this method when the command has been executed.
        /// </summary>
        /// <param name="result">The code factory model that has generated and provided to the command to process.</param>
        public override async Task ExecuteCommandAsync(VsProject result)
        {
            try
            {
                var projectReferences = await result.GetProjectReferencesAsync();


                bool isAspNetProject = projectReferences.Any(r => r.Name == AspNetConstants.MvcLibraryName);
                bool isPacWpfProject = projectReferences.Any(r => r.Name == WPFConstants.WPFAssemblyName);
                bool isPacProject    = projectReferences.Any(r => r.Name == WPFConstants.PACAssemblyName);

                if (isAspNetProject)
                {
                    await RegisterAspNetProjectAsync(result);

                    return;
                }

                if (isPacWpfProject)
                {
                    await RegisterWPFProjectAsync(result);

                    return;
                }

                if (isPacProject)
                {
                    await RegisterPacProjectAsync(result);

                    return;
                }

                await RegisterProjectAsync(result);
            }
            catch (Exception unhandledError)
            {
                _logger.Error($"The following unhandled error occured while executing the solution explorer project command {commandTitle}. ",
                              unhandledError);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Helper method that confirms a target project supports the microsoft extensions for dependency injection and Configuration.
        /// </summary>
        /// <param name="sourceProject">Target project to check.</param>
        /// <returns>True if found or false of not.</returns>
        public static async Task <bool> HasMicrosoftExtensionDependencyInjectionLibrariesAsync(VsProject sourceProject)
        {
            if (sourceProject == null)
            {
                return(false);
            }
            if (!sourceProject.IsLoaded)
            {
                return(false);
            }
            var references = await sourceProject.GetProjectReferencesAsync();

            //Checking for dependency injection libraries.
            bool returnResult = references.Any(r => r.Name == "Microsoft.Extensions.DependencyInjection.Abstractions");

            if (!returnResult)
            {
                return(false);
            }

            //Checking for the configuration libraries.
            returnResult = references.Any(r => r.Name == "Microsoft.Extensions.Configuration.Abstractions");
            return(returnResult);
        }