Beispiel #1
0
 private async Task <bool> IsComponentForDisplayAsync(Envoy envoy)
 {
     if ((envoy.ModelDefinitionType == ComponentDefinition.ModelDefinitionTypeKeyword ||
          envoy.BindingKeywords.Contains(ComponentDefinition.ModelDefinitionTypeKeyword)) &&
         envoy.OverridingModelDefinitionType != ComponentDefinition.ReferencedModelDefinitionTypeKeyword)
     {
         using (await envoy.LoadAsync())
         {
             IComponentSubtype subtype = envoy.GetOwningComponentConfigurationReference().Configuration.ComponentSubtype;
             return(CanBuildSubtype(subtype));
         }
     }
     return(false);
 }
Beispiel #2
0
        private async Task <bool> LoadAndBuildComponentEnvoyAsync(Envoy componentEnvoy)
        {
            CommandLineInterfaceApplication.WriteLineVerbose($"Resolved to {componentEnvoy.Name.Last}");

            ILockedSourceFile componentFileLock;

            try
            {
                componentFileLock = await componentEnvoy.LoadAsync();
            }
            catch (Exception e) when(ExceptionHelper.ShouldExceptionBeCaught(e))
            {
                string loadErrorMessage = DocumentExtensions.GetLoadErrorMessageForException(e, componentEnvoy.FileName());

                throw new CommandLineOperationException(loadErrorMessage, e);
            }
            using (componentFileLock)
            {
                CommandLineInterfaceApplication.WriteLineVerbose($"Loaded {componentEnvoy.Name.Last}");
                var configurationReference = componentEnvoy.GetOwningComponentConfigurationReference();
                if (ShowErrorIfSubTypeNotSupported(configurationReference))
                {
                    return(false);
                }
                bool buildSucceeded = await BuildComponentAsync(configurationReference);

                bool saveFailed = Save && !await TrySaveProjectFilesAsync(componentEnvoy.Project);

                if (!buildSucceeded || saveFailed)
                {
                    CommandLineInterfaceApplication.WriteError(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            LocalizedStrings.BuildComponentTool_BuildFailed,
                            componentEnvoy.Name.Last));
                    return(false);
                }

                WriteSuccessMessage(componentEnvoy.Name.Last, configurationReference.Configuration.GetOutputDirectory());
                return(true);
            }
        }