protected override FrameworkDependencyStatus GenerateConfiguration()
        {
            object isODataAssemblyReferenced;

            Context.Items.TryGetProperty(ContextKeys.IsODataAssemblyReferencedKey, out isODataAssemblyReferenced);

            object isWebApiAssemblyReferenced;

            Context.Items.TryGetProperty(ContextKeys.IsWebApiAssemblyReferencedKey, out isWebApiAssemblyReferenced);

            bool showODataReadme        = !(bool)isODataAssemblyReferenced;
            bool showWebApiReadme       = !(bool)isWebApiAssemblyReferenced;
            bool isNewGlobalAsaxCreated = TryCreateGlobalAsax();

            if (isNewGlobalAsaxCreated && showODataReadme)
            {
                return(FrameworkDependencyStatus.FromReadme(ODataReadMe.CreateReadMeText()));
            }
            else if (!isNewGlobalAsaxCreated)
            {
                string readmeText = String.Empty;

                if (showODataReadme)
                {
                    readmeText += ODataReadMe.CreateReadMeText();
                }

                if (showWebApiReadme)
                {
                    // WebApiReadMe readMeGenerator = new WebApiReadMe(Context.ActiveProject.GetCodeLanguage(), Context.ActiveProject.Name, AppStartFileNames);
                    // readmeText += readMeGenerator.CreateReadMeText();
                }

                if (!String.IsNullOrEmpty(readmeText))
                {
                    return(FrameworkDependencyStatus.FromReadme(readmeText));
                }
            }

            return(FrameworkDependencyStatus.InstallSuccessful);
        }
Beispiel #2
0
        public sealed override void GenerateCode()
        {
            FrameworkDependencyStatus dependencyStatus = FrameworkDependencyStatus.InstallNotNeeded;

            if (Framework.IsDependencyInstalled(Context))
            {
                Context.AddTelemetryData(TelemetrySharedKeys.DependencyScaffolderOptions, (uint)DependencyScaffolderOptions.AlreadyInstalled);
            }
            else
            {
                dependencyStatus = Framework.EnsureDependencyInstalled(Context);
            }

            Scaffold();

            if (dependencyStatus.IsNewDependencyInstall)
            {
                Framework.UpdateConfiguration(Context);
            }

            if (Model.OutputFileFullPath != null)
            {
                VisualStudioIntegration.Editor.OpenFileInEditor(Model.OutputFileFullPath);
            }

            // The readme is opened after the output file if needed, we want it to stay on top
            if (dependencyStatus.IsReadmeRequired)
            {
                VisualStudioIntegration.Editor.CreateAndOpenReadme(dependencyStatus.ReadmeText);
            }

            // Settings are only saved if scaffolding is successful
            SaveSettings(Model);

            // Adding the list of all the runtime dependency packages to the Context. Scaffolding core will install these
            // dependencies after the GenerateCode function is executed.
            foreach (NuGetPackage package in RuntimePackages)
            {
                Context.Packages.Add(package);
            }
        }