Example #1
0
        /// <inheritdoc/>
        public void Perform()
        {
            var boundedContextConfig = _boundedContextLoader.Load(_configuration.BoundedContextConfigPath);

            _artifactsDiscoverer      = new ArtifactsDiscoverer(_buildTarget.AssemblyContext, _artifactTypes, _buildMessages);
            _eventProcessorDiscoverer = new EventProcessorDiscoverer(_buildTarget.AssemblyContext, _buildMessages);

            var artifacts = _artifactsDiscoverer.Artifacts;

            var topology = _topologyConfigurationHandler.Build(artifacts, _configuration);

            var artifactsConfiguration = _artifactsConfigurationHandler.Build(artifacts, topology, _configuration);

            ValidateEventProcessors(_eventProcessorDiscoverer.GetAllEventProcessors());

            var events = artifacts.Where(_ => _artifactTypes.Where(artifactType => artifactType.TypeName == "event").First().Type.IsAssignableFrom(_));

            ValidateEvents(events);

            _topologyConfigurationHandler.Save(topology);
            _artifactsConfigurationHandler.Save(artifactsConfiguration);

            if (_configuration.GenerateProxies)
            {
                _proxiesHandler.CreateProxies(artifacts, _configuration, artifactsConfiguration);
            }
        }
Example #2
0
        static int Main(string[] args)
        {
            try
            {
                _logger.Information("Build process started");

                var startTime      = DateTime.UtcNow;
                var parsingResults = ArgumentsParser.Parse(args);
                var clientAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(parsingResults.AssemblyPath);
                InitialSetup();

                var boundedContextConfig = _boundedContextLoader.Load(parsingResults.BoundedContextConfigRelativePath);

                var assemblyContext = AssemblyContext.From(clientAssembly);

                _artifactsDiscoverer      = new ArtifactsDiscoverer(assemblyContext, _artifactTypes, _logger);
                _eventProcessorDiscoverer = new EventProcessorDiscoverer(assemblyContext, _logger);

                var artifacts = _artifactsDiscoverer.Artifacts;

                var topology = _topologyConfigurationHandler.Build(artifacts, parsingResults);

                var artifactsConfiguration = _artifactsConfigurationHandler.Build(artifacts, topology, parsingResults);

                ValidateEventProcessors(_eventProcessorDiscoverer.GetAllEventProcessors());

                var events = artifacts.Where(_ => _artifactTypes.ArtifactTypes.Where(artifactType => artifactType.TypeName == "event").First().Type.IsAssignableFrom(_));
                ValidateEvents(events);

                _topologyConfigurationHandler.Save(topology);
                _artifactsConfigurationHandler.Save(artifactsConfiguration);

                if (parsingResults.GenerateProxies)
                {
                    _proxiesHandler = _bootLoaderResult.Container.Get <ProxiesHandler>();
                    _proxiesHandler.CreateProxies(artifacts, parsingResults, artifactsConfiguration);
                }

                var endTime   = DateTime.UtcNow;
                var deltaTime = endTime.Subtract(startTime);
                _logger.Information($"Finished build process. (Took {deltaTime.TotalSeconds} seconds)");
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Error consolidating artifacts;");
                return(1);
            }

            return(0);
        }