예제 #1
0
        public static (string ProjectType, string Framework, string Platform) ReadProjectConfiguration()
        {
            var projectMetadata = ProjectMetadataService.GetProjectMetadata();

            if (!string.IsNullOrEmpty(projectMetadata.ProjectType) && !string.IsNullOrEmpty(projectMetadata.Framework) && !string.IsNullOrEmpty(projectMetadata.Platform))
            {
                return(projectMetadata.ProjectType, projectMetadata.Framework, projectMetadata.Platform);
            }

            var inferredConfig = InferProjectConfiguration(projectMetadata.ProjectType, projectMetadata.Framework, projectMetadata.Platform);

            if (!string.IsNullOrEmpty(inferredConfig.ProjectType) && !string.IsNullOrEmpty(inferredConfig.Framework) && !string.IsNullOrEmpty(inferredConfig.Platform))
            {
                ProjectMetadataService.SaveProjectMetadata(inferredConfig.ProjectType, inferredConfig.Framework, inferredConfig.Platform);
            }

            return(inferredConfig);
        }
        public static ProjectMetadata ReadProjectConfiguration()
        {
            var projectMetadata = ProjectMetadataService.GetProjectMetadata();

            if (IsValid(projectMetadata))
            {
                return(projectMetadata);
            }

            var inferredConfig = InferProjectConfiguration(projectMetadata);

            if (IsValid(inferredConfig))
            {
                ProjectMetadataService.SaveProjectMetadata(inferredConfig);
            }

            return(inferredConfig);
        }
        public bool Visible(TemplateType templateType)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (!_shell.GetActiveProjectIsWts())
            {
                return(false);
            }

            var projectPlatform = ProjectMetadataService.GetProjectMetadata(_shell.GetActiveProjectPath()).Platform;

            if (availableOptions.ContainsKey(projectPlatform) && availableOptions[projectPlatform].Contains(templateType))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        public ValidationResult Validate()
        {
            var result      = new ValidationResult();
            var projectType = ProjectMetadataService.GetProjectMetadata(GenContext.ToolBox.Shell.GetActiveProjectPath()).ProjectType;

            if (projectType == "SplitView" && HasOldNavigationView())
            {
                var message = new ValidationMessage
                {
                    Message          = Resources.StringRes.ValidatorHasOldNavigationViewMessage,
                    Url              = string.Format(Resources.StringRes.ValidatorHasOldNavigationViewLink, Core.Configuration.Current.GitHubDocsUrl),
                    HyperLinkMessage = Resources.StringRes.ValidatorHasOldNavigationViewLinkMessage,
                };

                result.IsValid = false;
                result.ErrorMessages.Add(message);
            }

            return(result);
        }
예제 #5
0
        public ValidationResult Validate()
        {
            var result    = new ValidationResult();
            var framework = ProjectMetadataService.GetProjectMetadata(GenContext.ToolBox.Shell.GetActiveProjectPath()).Framework;

            if (framework == "MVVMLight" && HasLocatorAsApplicationResource())
            {
                var message = new ValidationMessage
                {
                    Message          = Resources.StringRes.ValidatorHasOldMvvmLightLocatorMessage,
                    Url              = string.Format(Resources.StringRes.ValidatorHasOldMvvmLightLocatorLink, Core.Configuration.Current.GitHubDocsUrl),
                    HyperLinkMessage = Resources.StringRes.ValidatorHasOldMvvmLightLocatorLinkMessage,
                };

                result.IsValid = false;
                result.ErrorMessages.Add(message);
            }

            return(result);
        }
        public ValidationResult Validate()
        {
            var result      = new ValidationResult();
            var projectType = ProjectMetadataService.GetProjectMetadata().ProjectType;

            if (projectType == "SplitView" && HasHamburgerMenu())
            {
                var message = new ValidationMessage
                {
                    Message          = Resources.StringRes.ValidatorHasHamburgerMenuMessage,
                    Url              = string.Format(Resources.StringRes.ValidatorHasHamburgerMenuLink, Core.Configuration.Current.GitHubDocsUrl),
                    HyperLinkMessage = Resources.StringRes.ValidatorHasHamburgerMenuLinkMessage,
                };

                result.IsValid = false;
                result.ErrorMessages.Add(message);
            }

            return(result);
        }
        private bool EnsureGenContextInitialized()
        {
            var projectLanguage = _shell.GetActiveProjectLanguage();
            var projectPlatform = ProjectMetadataService.GetProjectMetadata(_shell.GetActiveProjectPath()).Platform;

            if (!string.IsNullOrEmpty(projectLanguage))
            {
                if (GenContext.CurrentLanguage != projectLanguage || GenContext.CurrentPlatform != projectPlatform)
                {
#if DEBUG
                    GenContext.Bootstrap(new LocalTemplatesSource(string.Empty), _shell, projectPlatform, projectLanguage);
#else
                    var mstxFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "InstalledTemplates");
                    GenContext.Bootstrap(new RemoteTemplatesSource(projectPlatform, projectLanguage, mstxFilePath, new DigitalSignatureService()), _shell, projectPlatform, projectLanguage);
#endif
                }

                return(true);
            }

            return(false);
        }