├── netfusion ├── src │ ├── Common │ │ ├── NetFusion.Common.UnitTests │ │ │ ├── Usings.cs │ │ │ ├── Entity │ │ │ │ └── DynamicEntity.cs │ │ │ └── Extensions │ │ │ │ ├── TypeExtensions.cs │ │ │ │ ├── Collections │ │ │ │ └── SetTests.cs │ │ │ │ └── ObjectTests.cs │ │ ├── NetFusion.Common.Base │ │ │ ├── Validation │ │ │ │ ├── ValidationTypes.cs │ │ │ │ ├── IValidatableType.cs │ │ │ │ ├── ValidationService.cs │ │ │ │ └── IValidationService.cs │ │ │ ├── Serialization │ │ │ │ └── ICustomDeserialize.cs │ │ │ ├── ContentTypes.cs │ │ │ ├── Entity │ │ │ │ ├── IEntityToken.cs │ │ │ │ └── IAttributedEntity.cs │ │ │ ├── Logging │ │ │ │ ├── ITypeLog.cs │ │ │ │ └── ILogLevelControl.cs │ │ │ ├── NfExtensions.cs │ │ │ └── Scripting │ │ │ │ ├── ScriptPredicate.cs │ │ │ │ ├── IEntityScriptMetaRepository.cs │ │ │ │ └── NullEntityScriptingService.cs │ │ └── NetFusion.Common │ │ │ ├── Extensions │ │ │ ├── Collections │ │ │ │ └── DictionaryExtensions.cs │ │ │ └── Reflection │ │ │ │ └── ClassificationExtensions.cs │ │ │ └── NetFusion.Common.csproj │ ├── Messaging │ │ ├── NetFusion.Messaging.UnitTests │ │ │ ├── Usings.cs │ │ │ ├── Queries │ │ │ │ └── Mocks │ │ │ │ │ └── Queries.cs │ │ │ ├── Enrichers │ │ │ │ └── Mocks │ │ │ │ │ └── Enrichers.cs │ │ │ ├── Commands │ │ │ │ └── Mocks │ │ │ │ │ └── Commands.cs │ │ │ ├── Logging │ │ │ │ └── Mocks │ │ │ │ │ └── LoggingSinks.cs │ │ │ ├── TestSetup.cs │ │ │ ├── Messaging │ │ │ │ ├── Logging │ │ │ │ │ └── Mocks │ │ │ │ │ │ └── LoggingSinks.cs │ │ │ │ └── TestSetupExtensions.cs │ │ │ └── DomainEvents │ │ │ │ └── Mocks │ │ │ │ └── DomainEvents.cs │ │ ├── NetFusion.Messaging │ │ │ ├── GlobalUsings.cs │ │ │ ├── Filters │ │ │ │ ├── IMessageFilter.cs │ │ │ │ ├── IPreMessageFilter.cs │ │ │ │ └── IPostMessageFilter.cs │ │ │ ├── InProcessHandlerAttribute.cs │ │ │ ├── IMessageConsumer.cs │ │ │ ├── IncludeDerivedMessagesAttribute.cs │ │ │ ├── Routing │ │ │ │ ├── IRouteMeta.cs │ │ │ │ └── ConsumerRoute.cs │ │ │ ├── Logging │ │ │ │ ├── IMessageLogSink.cs │ │ │ │ ├── IMessageLogger.cs │ │ │ │ └── MessageLogger.cs │ │ │ ├── Enrichers │ │ │ │ └── IMessageEnricher.cs │ │ │ ├── Internal │ │ │ │ ├── IBatchMessagePublisher.cs │ │ │ │ └── IMessagePublisher.cs │ │ │ ├── IntegrationTypes.cs │ │ │ ├── IMessageDispatcherService.cs │ │ │ └── Exceptions │ │ │ │ ├── FilterException.cs │ │ │ │ └── EnricherException.cs │ │ └── NetFusion.Messaging.Types │ │ │ ├── Contracts │ │ │ ├── IDomainEvent.cs │ │ │ ├── IEventSource.cs │ │ │ ├── IQuery.cs │ │ │ ├── IMessageWithResult.cs │ │ │ └── ICommand.cs │ │ │ ├── DomainEvent.cs │ │ │ ├── QueryReadModel.cs │ │ │ ├── NetFusion.Messaging.Types.csproj │ │ │ └── MessageNamespaceAttribute.cs │ ├── Integration │ │ ├── NetFusion.Integration.UnitTests │ │ │ ├── Usings.cs │ │ │ ├── RabbitMQ │ │ │ │ ├── RpcQueueUnitTests.cs │ │ │ │ ├── EntitySettingsUnitTests.cs │ │ │ │ └── Mocks │ │ │ │ │ ├── TestRabbitEntityModule.cs │ │ │ │ │ ├── TestRabbitBusModule.cs │ │ │ │ │ └── TestMessageTypes.cs │ │ │ └── Bus │ │ │ │ └── Mocks │ │ │ │ ├── TestCommand.cs │ │ │ │ └── TestSerializationManager.cs │ │ ├── NetFusion.Integration.RabbitMQ │ │ │ ├── Plugin │ │ │ │ ├── Configs │ │ │ │ │ └── RabbitMqConfig.cs │ │ │ │ ├── Settings │ │ │ │ │ ├── PublishSettings.cs │ │ │ │ │ └── HostSettings.cs │ │ │ │ ├── IBusEntityModule.cs │ │ │ │ └── IBusModule.cs │ │ │ ├── Rpc │ │ │ │ └── Metadata │ │ │ │ │ ├── RpcQueueMeta.cs │ │ │ │ │ └── RpcPublishOptions.cs │ │ │ ├── Bus │ │ │ │ └── PublishOptions.cs │ │ │ ├── Internal │ │ │ │ ├── ReconnectionEventArgs.cs │ │ │ │ └── ConsumerErrorStrategy.cs │ │ │ └── GlobalUsings.cs │ │ ├── NetFusion.AMQP │ │ │ ├── Publisher │ │ │ │ ├── AmqpPropContext.cs │ │ │ │ ├── Queue.cs │ │ │ │ ├── IHostRegistry.cs │ │ │ │ └── Internal │ │ │ │ │ └── IPublisherModule.cs │ │ │ ├── Subscriber │ │ │ │ ├── HostAttribute.cs │ │ │ │ ├── QueueAttribute.cs │ │ │ │ └── Internal │ │ │ │ │ └── HostItemAttribute.cs │ │ │ ├── Settings │ │ │ │ └── AmqpHostSettings.cs │ │ │ └── NetFusion.AMQP.csproj │ │ ├── NetFusion.Integration.ServiceBus │ │ │ ├── Queues │ │ │ │ └── Metadata │ │ │ │ │ ├── QueuePublishOptions.cs │ │ │ │ │ └── QueueRouteMeta.cs │ │ │ ├── Rpc │ │ │ │ └── Metadata │ │ │ │ │ ├── RpcProcessingOptions.cs │ │ │ │ │ ├── RpcPublishOptions.cs │ │ │ │ │ └── RpcQueueMeta.cs │ │ │ ├── Topics │ │ │ │ └── Metadata │ │ │ │ │ └── TopicPublishOptions.cs │ │ │ ├── Plugin │ │ │ │ ├── Configs │ │ │ │ │ └── ServiceBusConfig.cs │ │ │ │ ├── Settings │ │ │ │ │ ├── RuleSettings.cs │ │ │ │ │ ├── BusSettings.cs │ │ │ │ │ └── TopicSettings.cs │ │ │ │ ├── INamespaceModule.cs │ │ │ │ ├── Modules │ │ │ │ │ └── NamespaceEntityModule.cs │ │ │ │ └── INamespaceEntityModule.cs │ │ │ ├── GlobalUsings.cs │ │ │ ├── Namespaces │ │ │ │ └── MessageProperties.cs │ │ │ └── IQueueResponseService.cs │ │ ├── NetFusion.Integration.Redis │ │ │ ├── Plugin │ │ │ │ ├── IBusEntityModule.cs │ │ │ │ ├── Modules │ │ │ │ │ ├── ChannelEntityModule.cs │ │ │ │ │ └── RedisModule.cs │ │ │ │ └── Settings │ │ │ │ │ ├── DbEndPoint.cs │ │ │ │ │ └── RedisSettings.cs │ │ │ ├── Internal │ │ │ │ ├── ChannelEntityContext.cs │ │ │ │ ├── CachedConnection.cs │ │ │ │ └── RedisLogTextWriter.cs │ │ │ ├── Subscriber │ │ │ │ └── ChannelSubscriberEntity.cs │ │ │ └── Publisher │ │ │ │ └── ChannelPublisherEntity.cs │ │ ├── NetFusion.Integration.Bus │ │ │ ├── Strategies │ │ │ │ ├── IBusEntityDisposeStrategy.cs │ │ │ │ ├── IBusEntityCreationStrategy.cs │ │ │ │ ├── IBusEntitySubscriptionStrategy.cs │ │ │ │ ├── IBusEntityStrategy.cs │ │ │ │ └── IBusEntityPublishStrategy.cs │ │ │ ├── Rpc │ │ │ │ └── RpcReplyException.cs │ │ │ ├── IBusRouter.cs │ │ │ ├── NetFusion.Integration.Bus.csproj │ │ │ └── MessageExtensions.cs │ │ └── IntegrationTests │ │ │ └── RabbitMQ │ │ │ ├── MockPublisherModule.cs │ │ │ ├── MockBusModule.cs │ │ │ └── MockSubscriberModule.cs │ ├── Core │ │ ├── NetFusion.Core.UnitTests │ │ │ ├── Usings.cs │ │ │ ├── Bootstrap │ │ │ │ └── Mocks │ │ │ │ │ ├── MockPluginConfigOne.cs │ │ │ │ │ ├── MockPluginConfigTwo.cs │ │ │ │ │ ├── ServiceRegistrationTests.cs │ │ │ │ │ └── MockPluginModules.cs │ │ │ ├── Health │ │ │ │ └── Mocks │ │ │ │ │ ├── HealthCheckModuleOne.cs │ │ │ │ │ └── HealthCheckModuleTwo.cs │ │ │ ├── Settings │ │ │ │ ├── Mocks │ │ │ │ │ └── MockSetttings.cs │ │ │ │ └── Setup │ │ │ │ │ └── TestSetup.cs │ │ │ └── Properties │ │ │ │ └── UrlFilterPropertyTests.cs │ │ ├── NetFusion.Core.Bootstrap │ │ │ ├── Plugins │ │ │ │ ├── IPluginKnownType.cs │ │ │ │ ├── IPluginConfig.cs │ │ │ │ ├── IPluginModuleService.cs │ │ │ │ ├── PluginSummary.cs │ │ │ │ └── PluginTypes.cs │ │ │ └── Health │ │ │ │ ├── IModuleHealthCheckProvider.cs │ │ │ │ └── HealthCheckResultType.cs │ │ ├── NetFusion.Core.Settings │ │ │ ├── IAppSettings.cs │ │ │ ├── SettingsValidationException.cs │ │ │ └── ConfigurationSectionAttribute.cs │ │ └── NetFusion.Core.TestFixtures │ │ │ ├── Plugins │ │ │ ├── MockHostPlugin.cs │ │ │ ├── MockCorePlugin.cs │ │ │ └── MockAppPlugin.cs │ │ │ └── NetFusion.Core.TestFixtures.csproj │ ├── Web │ │ ├── NetFusion.Web.UnitTests │ │ │ ├── Rest │ │ │ │ ├── ApiMetadata │ │ │ │ │ ├── Server │ │ │ │ │ │ ├── MetaBodyPost.cs │ │ │ │ │ │ ├── ResponseModel.cs │ │ │ │ │ │ ├── MetaResource.cs │ │ │ │ │ │ ├── QueryParamSource.cs │ │ │ │ │ │ ├── HeaderParamSource.cs │ │ │ │ │ │ └── MetaResourceMap.cs │ │ │ │ │ └── Setup │ │ │ │ │ │ └── AssertExtensions.cs │ │ │ │ ├── LinkGeneration │ │ │ │ │ ├── Server │ │ │ │ │ │ ├── StateEmbeddedModel.cs │ │ │ │ │ │ └── StateModel.cs │ │ │ │ │ └── Client │ │ │ │ │ │ └── ClientModelStub.cs │ │ │ │ ├── CodeGeneration │ │ │ │ │ ├── Server │ │ │ │ │ │ ├── ApiModelTwo.cs │ │ │ │ │ │ └── ApiModelOne.cs │ │ │ │ │ └── Setup │ │ │ │ │ │ └── TestSetup.cs │ │ │ │ ├── Resources │ │ │ │ │ └── Models │ │ │ │ │ │ ├── ReminderModel.cs │ │ │ │ │ │ ├── PaymentModel.cs │ │ │ │ │ │ └── AccountModel.cs │ │ │ │ ├── ClientRequests │ │ │ │ │ ├── Server │ │ │ │ │ │ ├── CustomerModel.cs │ │ │ │ │ │ ├── AddressModel.cs │ │ │ │ │ │ ├── CustomerResourceMap.cs │ │ │ │ │ │ └── ErrorController.cs │ │ │ │ │ └── Client │ │ │ │ │ │ ├── CustomerModel.cs │ │ │ │ │ │ └── AddressModel.cs │ │ │ │ ├── DocGeneration │ │ │ │ │ ├── Setup │ │ │ │ │ │ ├── PluginSetup.cs │ │ │ │ │ │ └── XmlCommentsSetup.cs │ │ │ │ │ └── Server │ │ │ │ │ │ ├── TestRequestModels.cs │ │ │ │ │ │ ├── DocResourceMap.cs │ │ │ │ │ │ └── TestResponseModels.cs │ │ │ │ └── Setup │ │ │ │ │ ├── NullUnitTestService.cs │ │ │ │ │ └── MockUnitTestService.cs │ │ │ ├── Mocks │ │ │ │ └── IMockedService.cs │ │ │ └── HalComments.json │ │ ├── NetFusion.Web.Rest.Resources │ │ │ ├── IResource.cs │ │ │ ├── EntryPointModel.cs │ │ │ ├── ResourceAttribute.cs │ │ │ ├── NetFusion.Web.Rest.Resources.csproj │ │ │ └── ResourceExtensions.cs │ │ ├── NetFusion.Web.Rest.Docs │ │ │ ├── Core │ │ │ │ ├── Descriptions │ │ │ │ │ ├── IDocDescription.cs │ │ │ │ │ ├── IEmbeddedDescription.cs │ │ │ │ │ ├── IActionDescription.cs │ │ │ │ │ ├── IResponseDescription.cs │ │ │ │ │ ├── IRelationDescription.cs │ │ │ │ │ └── IParameterDescription.cs │ │ │ │ ├── ITypeCommentService.cs │ │ │ │ └── IDocBuilder.cs │ │ │ ├── Entities │ │ │ │ ├── HalComments.cs │ │ │ │ ├── RelationComment.cs │ │ │ │ └── EmbeddedComment.cs │ │ │ ├── Models │ │ │ │ ├── ApiResponseDoc.cs │ │ │ │ ├── ApiRelationDoc.cs │ │ │ │ ├── ApiEmbeddedDoc.cs │ │ │ │ ├── ApiPropertyDoc.cs │ │ │ │ └── ApiParameterDoc.cs │ │ │ ├── Plugin │ │ │ │ ├── IDocModule.cs │ │ │ │ └── RestDocExtensions.cs │ │ │ └── Xml │ │ │ │ └── Descriptions │ │ │ │ ├── XmlActionComments.cs │ │ │ │ └── XmlParameterComments.cs │ │ ├── NetFusion.Web.Common │ │ │ ├── HttpHeaderNames.cs │ │ │ ├── InternetMediaTypes.cs │ │ │ └── NetFusion.Web.Common.csproj │ │ ├── NetFusion.Web.Rest.CodeGen │ │ │ ├── Plugin │ │ │ │ ├── ICodeGenModule.cs │ │ │ │ └── RestCodeGenExtensions.cs │ │ │ └── IApiCodeGenService.cs │ │ ├── NetFusion.Web.Rest.Server │ │ │ ├── Mappings │ │ │ │ └── IResourceProvider.cs │ │ │ ├── Linking │ │ │ │ ├── TemplateUrlLink.cs │ │ │ │ ├── ResourceLink.cs │ │ │ │ └── ControllerExtensions.cs │ │ │ ├── Plugin │ │ │ │ └── Modules │ │ │ │ │ └── ConcurrencyModule.cs │ │ │ ├── Hal │ │ │ │ ├── Core │ │ │ │ │ └── HalResourceMeta.cs │ │ │ │ └── IHalEmbeddedResourceContext.cs │ │ │ └── Meta │ │ │ │ └── IResourceMeta.cs │ │ ├── NetFusion.Web.Rest.Client │ │ │ ├── IRestClientFactory.cs │ │ │ ├── IRestClientService.cs │ │ │ ├── Core │ │ │ │ └── RestClientService.cs │ │ │ └── Settings │ │ │ │ └── IRequestSettings.cs │ │ └── NetFusion.Web │ │ │ ├── Plugin │ │ │ ├── Modules │ │ │ │ └── ApiMetadataModule.cs │ │ │ └── WebMvcPlugin.cs │ │ │ ├── Metadata │ │ │ └── ApiResponseMeta.cs │ │ │ ├── Extensions │ │ │ └── HttpContextExtensions.cs │ │ │ └── NetFusion.Web.csproj │ └── Services │ │ ├── NetFusion.Services.UnitTests │ │ ├── Mapping │ │ │ ├── Entities │ │ │ │ ├── Summary.cs │ │ │ │ ├── TestMapTypeOne.cs │ │ │ │ ├── CarSummary.cs │ │ │ │ ├── CustomerSummary.cs │ │ │ │ ├── TestMapTypeTwo.cs │ │ │ │ ├── TestMapTypeThree.cs │ │ │ │ ├── Customer.cs │ │ │ │ └── Car.cs │ │ │ └── Strategies │ │ │ │ ├── TestMapStrategyTwoToOne.cs │ │ │ │ ├── TestMapStrategyOneToThree.cs │ │ │ │ ├── TestMappingStrategyFactory.cs │ │ │ │ ├── TestMapStrategyOneToTwo.cs │ │ │ │ ├── TestMapStrategyThreeToTwo.cs │ │ │ │ └── TestDerivedStrategyFactory.cs │ │ ├── Usings.cs │ │ └── Roslyn │ │ │ └── DynamicEntity.cs │ │ ├── NetFusion.Services.Mapping │ │ ├── MappingException.cs │ │ ├── Plugin │ │ │ └── IMappingModule.cs │ │ ├── IMappingStrategyFactory.cs │ │ └── NetFusion.Services.Mapping.csproj │ │ ├── NetFusion.Services.Serialization │ │ ├── SerializationException.cs │ │ ├── JsonMessageSerializer.cs │ │ └── NetFusion.Services.Serialization.csproj │ │ ├── NetFusion.Services.Messaging │ │ ├── Enrichers │ │ │ ├── DateOccurredEnricher.cs │ │ │ ├── HostEnricher.cs │ │ │ └── CorrelationEnricher.cs │ │ └── NetFusion.Services.Messaging.csproj │ │ ├── NetFusion.Services.Roslyn │ │ └── Internal │ │ │ └── ExpressionEvaluator.cs │ │ └── NetFusion.Services.Serilog │ │ ├── ServiceCollectionExtensions.cs │ │ └── EnricherExtensions.cs ├── build │ ├── netfusion.png │ ├── credits.md │ └── common.props ├── NetFusion.sln.DotSettings └── .editorconfig ├── img ├── RefArch.png ├── netfusionlogo.png ├── project_logo.jpg ├── NetFusionLog-0.PNG ├── NetFusionLog-1.PNG ├── NetFusionLog-2.PNG ├── lightbulb-icon.png ├── Nuget-NetFusion.MongoDB.png ├── Nuget-NetFusion.WebApi.png ├── Nuget-netFusion.Common.png ├── Nuget-NetFusion.Bootstrap.png ├── Nuget-NetFusion.Messaging.png ├── Nuget-NetFusion.RabbitMQ.png ├── Nuget-NetFusion.Settings.png ├── Nuget-NetFusion.Integration.png ├── Nuget-NetFusion.EntityFramework.png ├── Nuget-NetFusion.Logging.Serilog.png └── Nuget-NetFusion.Settings.MongoDB.png ├── .github └── workflows │ └── branches-build.yml └── LICENSE /netfusion/src/Common/NetFusion.Common.UnitTests/Usings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/Usings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; -------------------------------------------------------------------------------- /img/RefArch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/RefArch.png -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.UnitTests/Usings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; -------------------------------------------------------------------------------- /img/netfusionlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/netfusionlogo.png -------------------------------------------------------------------------------- /img/project_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/project_logo.jpg -------------------------------------------------------------------------------- /img/NetFusionLog-0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/NetFusionLog-0.PNG -------------------------------------------------------------------------------- /img/NetFusionLog-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/NetFusionLog-1.PNG -------------------------------------------------------------------------------- /img/NetFusionLog-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/NetFusionLog-2.PNG -------------------------------------------------------------------------------- /img/lightbulb-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/lightbulb-icon.png -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Usings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; 2 | global using FluentAssertions; -------------------------------------------------------------------------------- /netfusion/build/netfusion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/netfusion/build/netfusion.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.MongoDB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.MongoDB.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.WebApi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.WebApi.png -------------------------------------------------------------------------------- /img/Nuget-netFusion.Common.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-netFusion.Common.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.Bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.Bootstrap.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.Messaging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.Messaging.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.RabbitMQ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.RabbitMQ.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.Settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.Settings.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.Integration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.Integration.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.EntityFramework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.EntityFramework.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.Logging.Serilog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.Logging.Serilog.png -------------------------------------------------------------------------------- /img/Nuget-NetFusion.Settings.MongoDB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grecosoft/NetFusion/HEAD/img/Nuget-NetFusion.Settings.MongoDB.png -------------------------------------------------------------------------------- /netfusion/build/credits.md: -------------------------------------------------------------------------------- 1 | Addon icons created by Freepik - Flaticon -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ApiMetadata/Server/MetaBodyPost.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.ApiMetadata.Server; 2 | 3 | public class MetaBodyPost; -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ApiMetadata/Server/ResponseModel.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.ApiMetadata.Server; 2 | 3 | public class ResponseModel; -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.UnitTests/RabbitMQ/RpcQueueUnitTests.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.UnitTests.RabbitMQ; 2 | 3 | public class RpcQueueUnitTests; -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.UnitTests/RabbitMQ/EntitySettingsUnitTests.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.UnitTests.RabbitMQ; 2 | 3 | public class EntitySettingsUnitTests; -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ApiMetadata/Server/MetaResource.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.ApiMetadata.Server; 2 | 3 | public class MetaResource 4 | { 5 | public int Id { get; set; } 6 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | // Common Bootstrap namespaces: 2 | 3 | // Common Messaging namespaces: 4 | global using NetFusion.Messaging.Internal; 5 | global using NetFusion.Messaging.Types.Contracts; -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Entities/Summary.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Services.UnitTests.Mapping.Entities; 2 | 3 | public abstract class Summary 4 | { 5 | public string? Description { get; set; } 6 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Resources/IResource.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Resources; 2 | 3 | /// 4 | /// Marker interface used to identity types of resources. 5 | /// 6 | public interface IResource; -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/LinkGeneration/Server/StateEmbeddedModel.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.LinkGeneration.Server; 2 | 3 | public class StateEmbeddedModel 4 | { 5 | public int Id { get; set; } 6 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Entities/TestMapTypeOne.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Services.UnitTests.Mapping.Entities; 2 | 3 | public class TestMapTypeOne 4 | { 5 | public int[] Values { get; set; } = Array.Empty(); 6 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Plugin/Configs/RabbitMqConfig.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.RabbitMQ.Plugin.Configs; 2 | 3 | public class RabbitMqConfig : IPluginConfig 4 | { 5 | public bool IsAutoCreateEnabled { get; set; } 6 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Entities/CarSummary.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Services.UnitTests.Mapping.Entities; 2 | 3 | public class CarSummary : Summary 4 | { 5 | public string? Make { get; set; } 6 | public string? Model { get; set; } 7 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Mapping/MappingException.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Exceptions; 2 | 3 | namespace NetFusion.Services.Mapping; 4 | 5 | public class MappingException(string message, string? exceptionId = null) : NetFusionException(message, exceptionId); -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Entities/CustomerSummary.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Services.UnitTests.Mapping.Entities; 2 | 3 | public class CustomerSummary : Summary 4 | { 5 | public string? FirstName { get; set; } 6 | public string? LastName { get; set; } 7 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Bootstrap/Mocks/MockPluginConfigOne.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | 3 | namespace NetFusion.Core.UnitTests.Bootstrap.Mocks; 4 | 5 | public class MockPluginConfigOne : IPluginConfig 6 | { 7 | public string ConfigValue { get; set; } 8 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Bootstrap/Mocks/MockPluginConfigTwo.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | 3 | namespace NetFusion.Core.UnitTests.Bootstrap.Mocks; 4 | 5 | public class MockPluginConfigTwo : IPluginConfig 6 | { 7 | public string ConfigValue { get; set; } 8 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Filters/IMessageFilter.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Filters; 2 | 3 | /// 4 | /// Common marker interface representing a class that is invoked 5 | /// during the dispatching of a messing. 6 | /// 7 | public interface IMessageFilter; -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Entities/TestMapTypeTwo.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Services.UnitTests.Mapping.Entities; 2 | 3 | public class TestMapTypeTwo 4 | { 5 | public int Sum { get; set; } 6 | public int Max { get; set; } 7 | public int Min { get; set; } 8 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Entities/TestMapTypeThree.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Services.UnitTests.Mapping.Entities; 2 | 3 | public class TestMapTypeThree 4 | { 5 | public int MaxAllowedValue { get; set; } 6 | public int[] Values { get; set; } = Array.Empty(); 7 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Rpc/Metadata/RpcQueueMeta.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.RabbitMQ.Rpc.Metadata; 2 | 3 | public class RpcQueueMeta(string queueName) 4 | { 5 | public string QueueName { get; } = queueName; 6 | public ushort PrefetchCount { get; set; } = 10; 7 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Serialization/SerializationException.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Exceptions; 2 | 3 | namespace NetFusion.Services.Serialization; 4 | 5 | public class SerializationException(string message, string? exceptionId = null) 6 | : NetFusionException(message, exceptionId); -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Validation/ValidationTypes.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Common.Base.Validation; 2 | 3 | /// 4 | /// Possible validation levels. 5 | /// 6 | public enum ValidationTypes 7 | { 8 | Valid = 0, 9 | Info = 1, 10 | Warning = 2, 11 | Error = 3 12 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Usings.cs: -------------------------------------------------------------------------------- 1 | global using FluentAssertions; 2 | global using NetFusion.Core.TestFixtures.Container; 3 | global using NetFusion.Core.TestFixtures.Extensions; 4 | global using NetFusion.Core.TestFixtures.Plugins; 5 | global using Xunit; 6 | global using NetFusion.Messaging.Types; -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Bootstrap/Plugins/IPluginKnownType.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Core.Bootstrap.Plugins; 2 | 3 | /// 4 | /// A marker interface used to identify types within a plugin that 5 | /// can be implemented by concrete types within other plugins. 6 | /// 7 | public interface IPluginKnownType; -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Serialization/ICustomDeserialize.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Common.Base.Serialization; 2 | 3 | /// 4 | /// Interface implemented by message to provide custom deserialization. 5 | /// 6 | public interface ICustomDeserialize 7 | { 8 | void Deserialize(byte[] value); 9 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Bootstrap/Plugins/IPluginConfig.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Core.Bootstrap.Plugins; 2 | 3 | /// 4 | /// Allows plug-ins to define specific configurations that can be initialized by the host 5 | /// application to alter the behavior of the plugin. 6 | /// 7 | public interface IPluginConfig; -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/CodeGeneration/Server/ApiModelTwo.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Resources; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.CodeGeneration.Server; 4 | 5 | /// 6 | /// Example model for which code will be generated. 7 | /// 8 | [Resource("ResourceTwo")] 9 | public class ApiModelTwo; -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/Publisher/AmqpPropContext.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.AMQP.Publisher 2 | { 3 | /// 4 | /// Marker class used to associate scope with message attributes 5 | /// set and used by this plugin. 6 | /// 7 | public class AmqpPropContext 8 | { 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/ContentTypes.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Common.Base; 2 | 3 | /// 4 | /// Common serialization type MIME values. 5 | /// 6 | public static class ContentTypes 7 | { 8 | public const string Json = "application/json"; 9 | public const string MessagePack = "application/x-msgpack"; 10 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Settings/IAppSettings.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Core.Settings; 2 | 3 | /// 4 | /// Interface representing a class containing application settings. An instance of 5 | /// the implementing class is created and initialized when injected into a dependent 6 | /// component. 7 | /// 8 | public interface IAppSettings; -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Entities/Customer.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Services.UnitTests.Mapping.Entities; 2 | 3 | public class Customer(string firstName, string lastName, int age) 4 | { 5 | public string FirstName { get; } = firstName; 6 | public string LastName { get; } = lastName; 7 | public int Age { get; } = age; 8 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.UnitTests/Bus/Mocks/TestCommand.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Types; 2 | 3 | namespace NetFusion.Integration.UnitTests.Bus.Mocks; 4 | 5 | public class TestCommand : Command; 6 | 7 | public class TestCommandConsumer 8 | { 9 | public void OnCommand(TestCommand command) 10 | { 11 | 12 | } 13 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Plugin/Settings/PublishSettings.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.RabbitMQ.Plugin.Settings; 2 | 3 | public class PublishSettings 4 | { 5 | public string? ContentType { get; set; } 6 | public byte? Priority { get; set; } 7 | public bool? IsPersistent { get; set; } 8 | public bool? IsMandatory { get; set; } 9 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ApiMetadata/Server/QueryParamSource.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.ApiMetadata.Server; 4 | 5 | public class QueryParamSource 6 | { 7 | [FromQuery] 8 | public string Filter { get; set; } 9 | 10 | [FromQuery] 11 | public string Version { get; set; } 12 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Entities/Car.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Services.UnitTests.Mapping.Entities; 2 | 3 | public class Car(string make, string model, string color, int year) 4 | { 5 | public string Make { get; } = make; 6 | public string Model { get; } = model; 7 | public string Color { get; } = color; 8 | public int Year { get; set; } = year; 9 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Plugin/IBusEntityModule.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using NetFusion.Integration.Bus.Entities; 3 | 4 | namespace NetFusion.Integration.RabbitMQ.Plugin; 5 | 6 | public interface IBusEntityModule : IPluginModuleService 7 | { 8 | bool TryGetPublishEntityForMessage(Type messageType, [NotNullWhen(true)] out BusEntity? entity); 9 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/Queries/Mocks/Queries.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Types; 2 | 3 | namespace NetFusion.Messaging.UnitTests.Queries.Mocks; 4 | 5 | public class MockQuery : Query 6 | { 7 | public List QueryAsserts { get; } = []; 8 | public List ThrowInHandlers { get; } = []; 9 | } 10 | 11 | public class MockQueryResult; -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/Resources/Models/ReminderModel.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Resources; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.Resources.Models; 4 | 5 | /// 6 | /// Represents a model returned from a REST Api. 7 | /// 8 | [Resource("ReminderResource")] 9 | public class ReminderModel 10 | { 11 | public string Message { get; set; } 12 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/InProcessHandlerAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging 2 | { 3 | /// 4 | /// Used to specify that a consumer's message handler method should be 5 | /// invoked by the InProcessMessagePublisher. 6 | /// 7 | [AttributeUsage(AttributeTargets.Method)] 8 | public class InProcessHandlerAttribute : Attribute; 9 | } 10 | -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ApiMetadata/Server/HeaderParamSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace NetFusion.Web.UnitTests.Rest.ApiMetadata.Server; 5 | 6 | public class HeaderParamSource 7 | { 8 | [FromHeader] 9 | public string ClientId { get; set; } 10 | 11 | [FromHeader] 12 | public DateTime AsOfDate { get; set; } 13 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/CodeGeneration/Server/ApiModelOne.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Resources; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.CodeGeneration.Server; 4 | 5 | /// 6 | /// Example model for which code will be generated. 7 | /// 8 | [Resource("ResourceOne")] 9 | public class ApiModelOne 10 | { 11 | public string ModelOneProp { get; set; } 12 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Queues/Metadata/QueuePublishOptions.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base; 2 | 3 | namespace NetFusion.Integration.ServiceBus.Queues.Metadata; 4 | 5 | /// 6 | /// Options used when a command is published to the queue. 7 | /// 8 | public class QueuePublishOptions 9 | { 10 | public string ContentType { get; set; } = ContentTypes.Json; 11 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/LinkGeneration/Client/ClientModelStub.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.LinkGeneration.Client; 2 | 3 | /// 4 | /// A model used on the client-side of the tests into which responses 5 | /// are deserialized. When testing links, we only care about the links 6 | /// on the associated resource containing the model. 7 | /// 8 | public class ClientModelStub; -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Entity/IEntityToken.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Common.Base.Entity; 2 | 3 | /// 4 | /// Interface implemented to indicate optimistic concurrency check 5 | /// is required upon update. 6 | /// 7 | public interface IEntityToken 8 | { 9 | /// 10 | /// The token associated with the current state. 11 | /// 12 | string? Token { get; } 13 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Rpc/Metadata/RpcPublishOptions.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base; 2 | 3 | namespace NetFusion.Integration.RabbitMQ.Rpc.Metadata; 4 | 5 | public class RpcPublishOptions 6 | { 7 | public int CancelRpcRequestAfterMs { get; set; } = 5_000; 8 | public string ContentType { get; set; } = ContentTypes.Json; 9 | public ushort ResponseQueuePrefetchCount { get; set; } = 1; 10 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Core/Descriptions/IDocDescription.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Core.Descriptions; 2 | 3 | /// 4 | /// Marker interface identifying a class responsible for adding additional 5 | /// documentation to a REST Api action method document. For example, comments 6 | /// stored within .NET code XML files can be queried and added to the model. 7 | /// 8 | public interface IDocDescription; -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Logging/ITypeLog.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Common.Base.Logging; 2 | 3 | /// 4 | /// Implemented by a type to determine what state should be logged. 5 | /// 6 | public interface ITypeLog 7 | { 8 | /// 9 | /// Should return subset of a type's state to be logged. 10 | /// 11 | /// State to be logged. 12 | object Log(); 13 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Plugin/IBusEntityModule.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using NetFusion.Core.Bootstrap.Plugins; 3 | using NetFusion.Integration.Bus.Entities; 4 | 5 | namespace NetFusion.Integration.Redis.Plugin; 6 | 7 | public interface IBusEntityModule : IPluginModuleService 8 | { 9 | bool TryGetPublishEntityForMessage(Type messageType, [NotNullWhen(true)] out BusEntity? entity); 10 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/Resources/Models/PaymentModel.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Resources; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.Resources.Models; 4 | 5 | /// 6 | /// Represents a model returned from a REST Api. 7 | /// 8 | [Resource("PaymentResource")] 9 | public class PaymentModel 10 | { 11 | public string PaymentId { get; set; } 12 | public decimal Amount { get; set; } 13 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.TestFixtures/Plugins/MockHostPlugin.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | 3 | namespace NetFusion.Core.TestFixtures.Plugins; 4 | 5 | /// 6 | /// The host plug-in represents the executing host application such as 7 | /// a WebApi or Console host. A container can only have one associated 8 | /// host plug-in. 9 | /// 10 | public class MockHostPlugin() : MockPlugin(PluginTypes.HostPlugin); -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Rpc/Metadata/RpcProcessingOptions.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.ServiceBus.Rpc.Metadata; 2 | 3 | /// 4 | /// Options used when processing RPC commands. 5 | /// 6 | public class RpcProcessingOptions 7 | { 8 | public int PrefetchCount { get; set; } = 10; 9 | public int MaxConcurrentCalls { get; set; } = 20; 10 | public string? Identifier { get; set; } 11 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Mocks/IMockedService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NetFusion.Web.Rest.Resources; 3 | 4 | namespace NetFusion.Web.UnitTests.Mocks; 5 | 6 | public interface IMockedService 7 | { 8 | HalResource ServerReceivedResource { get; set; } 9 | 10 | IEnumerable GetResources(); 11 | 12 | bool TriggerServerSideException { get; set; } 13 | 14 | int ReturnsStatusCode { get; set; } 15 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/Resources/Models/AccountModel.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Resources; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.Resources.Models; 4 | 5 | /// 6 | /// Represents a model returned from a REST Api. 7 | /// 8 | [Resource("AccountResource")] 9 | public class AccountModel 10 | { 11 | public string AccountNumber { get; set; } 12 | public decimal AvailableBalance { get; set; } 13 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Bus/PublishOptions.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base; 2 | 3 | namespace NetFusion.Integration.RabbitMQ.Bus; 4 | 5 | // Options used when publishing a message. 6 | public class PublishOptions 7 | { 8 | public string ContentType { get; set; } = ContentTypes.Json; 9 | public byte? Priority { get; set; } 10 | public bool IsPersistent { get; set; } 11 | public bool IsMandatory { get; set; } 12 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Rpc/Metadata/RpcPublishOptions.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base; 2 | 3 | namespace NetFusion.Integration.ServiceBus.Rpc.Metadata; 4 | 5 | /// 6 | /// Options used when sending a RPC command to a queue. 7 | /// 8 | public class RpcPublishOptions 9 | { 10 | public int CancelRpcRequestAfterMs { get; set; } = 5_000; 11 | public string ContentType { get; set; } = ContentTypes.Json; 12 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Common/HttpHeaderNames.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Common; 2 | 3 | /// 4 | /// Common HTTP header name constants. 5 | /// 6 | public static class HttpHeaderNames 7 | { 8 | /// 9 | /// Accept 10 | /// 11 | public const string Accept = "Accept"; 12 | 13 | /// 14 | /// Content-Type 15 | /// 16 | public const string ContentType = "Content-Type"; 17 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/Enrichers/Mocks/Enrichers.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Enrichers; 2 | using NetFusion.Messaging.Types.Contracts; 3 | 4 | namespace NetFusion.Messaging.UnitTests.Enrichers.Mocks; 5 | 6 | public class MockEnricherWithException : IMessageEnricher 7 | { 8 | public Task EnrichAsync(IMessage message) 9 | { 10 | return Task.Run(() => throw new InvalidOperationException("TestEnricherException")); 11 | } 12 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/IMessageConsumer.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging 2 | { 3 | /// 4 | /// Identifies component as a message consumer that should be searched when messages are published. 5 | /// This search happens during the bootstrapping of the plug-in and all found components are registered 6 | /// with the service-collection as scoped components. 7 | /// 8 | public interface IMessageConsumer; 9 | } 10 | -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ApiMetadata/Server/MetaResourceMap.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Server.Hal; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.ApiMetadata.Server; 4 | 5 | public class MetaResourceMap : HalResourceMap 6 | { 7 | protected override void OnBuildResourceMap() 8 | { 9 | Map() 10 | .LinkMeta(_ => 11 | { 12 | 13 | }); 14 | } 15 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ClientRequests/Server/CustomerModel.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.ClientRequests.Server; 2 | 3 | /// 4 | /// Server side resource returned by the API Controller under-test. 5 | /// 6 | public class CustomerModel 7 | { 8 | public string CustomerId { get; set; } 9 | public string FirstName { get; set; } 10 | public string LastName { get; set; } 11 | public int Age { get; set; } 12 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Bootstrap/Plugins/IPluginModuleService.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Core.Bootstrap.Plugins; 2 | 3 | /// 4 | /// Marker interface used to identify interfaces implemented by modules providing access to information 5 | /// it manages. All, modules implementing an interface derived from this type will be added to the 6 | /// dependency-injection container as singletons of the derived interface type. 7 | /// 8 | public interface IPluginModuleService; -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ClientRequests/Client/CustomerModel.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.ClientRequests.Client; 2 | 3 | /// 4 | /// Client side resource class modeling the corresponding 5 | /// server side returned resource. 6 | /// 7 | public class CustomerModel 8 | { 9 | public string CustomerId { get; set; } 10 | public string FirstName { get; set; } 11 | public string LastName { get; set; } 12 | public int Age { get; set; } 13 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.TestFixtures/Plugins/MockCorePlugin.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | 3 | namespace NetFusion.Core.TestFixtures.Plugins; 4 | 5 | /// 6 | /// Mock core plug-in that can be used for testing. In the composite container, 7 | /// core plug-ins implement cross-cutting concerns and implement specific technical 8 | /// details used to support the application domain. 9 | /// 10 | public class MockCorePlugin() : MockPlugin(PluginTypes.CorePlugin); -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/IncludeDerivedMessagesAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging 2 | { 3 | /// 4 | /// Used to specify that message handler method, declared as a base message type, 5 | /// should be called when derived messages are published. This allows a single 6 | /// handler to be invoked for a several derived message types. 7 | /// 8 | [AttributeUsage(AttributeTargets.Parameter)] 9 | public class IncludeDerivedMessagesAttribute : Attribute; 10 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/Commands/Mocks/Commands.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Types; 2 | 3 | namespace NetFusion.Messaging.UnitTests.Commands.Mocks; 4 | 5 | public class MockCommand : Command 6 | { 7 | public List ThrowInHandlers { get; } = []; 8 | } 9 | 10 | public class MockCommandNoResult : Command; 11 | 12 | public class MockCommandNoHandler : Command; 13 | 14 | public class MockCommandResult 15 | { 16 | public string Value { get; set; } = string.Empty; 17 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/Contracts/IDomainEvent.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Types.Contracts; 2 | 3 | /// 4 | /// Message that can be published to notify application consumers of an occurrence. 5 | /// Domain-events are used to notify one or more consumers of an occurrence of an event. 6 | /// Often, command handlers will publish domain-events used to notify interested subscribers 7 | /// of state changes made by the handling of the command. 8 | /// 9 | public interface IDomainEvent : IMessage; -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Plugin/IBusModule.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.RabbitMQ.Bus; 2 | using NetFusion.Integration.RabbitMQ.Internal; 3 | using NetFusion.Integration.RabbitMQ.Plugin.Configs; 4 | 5 | namespace NetFusion.Integration.RabbitMQ.Plugin; 6 | 7 | public interface IBusModule : IPluginModuleService 8 | { 9 | RabbitMqConfig RabbitMqConfig { get; } 10 | 11 | IBusConnection GetConnection(string busName); 12 | 13 | public event EventHandler? Reconnection; 14 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Topics/Metadata/TopicPublishOptions.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base; 2 | 3 | namespace NetFusion.Integration.ServiceBus.Topics.Metadata; 4 | 5 | /// 6 | /// Default options used when publishing a domain-event to a topic. 7 | /// 8 | public class TopicPublishOptions 9 | { 10 | /// 11 | /// The content-type to use when serializing the domain-event. 12 | /// 13 | public string ContentType { get; set; } = ContentTypes.Json; 14 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/Strategies/IBusEntityDisposeStrategy.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.Bus.Strategies; 2 | 3 | /// 4 | /// Strategy invoked when the microservice is stopped used 5 | /// to dispose a created service-bus entity. 6 | /// 7 | public interface IBusEntityDisposeStrategy : IBusEntityStrategy 8 | { 9 | /// 10 | /// Called when the entity should be disposed. 11 | /// 12 | /// Future Result. 13 | Task OnDispose(); 14 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.UnitTests/RabbitMQ/Mocks/TestRabbitEntityModule.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.Bus; 2 | using NetFusion.Integration.Bus.Entities; 3 | using NetFusion.Integration.RabbitMQ.Plugin.Modules; 4 | 5 | namespace NetFusion.Integration.UnitTests.RabbitMQ.Mocks; 6 | 7 | public class TestRabbitEntityModule : BusEntityModule 8 | { 9 | // Set by bootstrapper: 10 | protected IEnumerable Routers => BusMessageRouters; 11 | 12 | public IEnumerable Entities => BusEntities; 13 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/Contracts/IEventSource.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Types.Contracts; 2 | 3 | /// 4 | /// Implemented by an entity that can have associated domain events. 5 | /// This can be used to decouple domain entities from the infrastructure 6 | /// used to publish the events. 7 | /// 8 | public interface IEventSource 9 | { 10 | /// 11 | /// The domain events associated with the entity. 12 | /// 13 | IEnumerable DomainEvents { get; } 14 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Strategies/TestMapStrategyTwoToOne.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Services.Mapping; 2 | using NetFusion.Services.UnitTests.Mapping.Entities; 3 | 4 | namespace NetFusion.Services.UnitTests.Mapping.Strategies; 5 | 6 | public class TestMapStrategyTwoToOne : MappingStrategy 7 | { 8 | protected override TestMapTypeOne SourceToTarget(TestMapTypeTwo target) => 9 | new() 10 | { 11 | Values = [target.Min, target.Max, target.Sum] 12 | }; 13 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ClientRequests/Client/AddressModel.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.ClientRequests.Client; 2 | 3 | /// 4 | /// Client side resource class modeling the corresponding 5 | /// server side returned resource. 6 | /// 7 | public class AddressModel 8 | { 9 | public string AddressId { get; set; } 10 | public string CustomerId { get; set; } 11 | public string Street { get; set; } 12 | public string City { get; set; } 13 | public string ZipCode { get; set; } 14 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/NfExtensions.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Logging; 2 | 3 | namespace NetFusion.Common.Base; 4 | 5 | /// 6 | /// Static class containing references to global class instances 7 | /// initialized at the beginning of the bootstrap process. 8 | /// 9 | public static class NfExtensions 10 | { 11 | /// 12 | /// Reference to a logger implementation providing extended logging. 13 | /// 14 | public static IExtendedLogger Logger { get; set; } = new NullExtendedLogger(); 15 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/Strategies/IBusEntityCreationStrategy.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.Bus.Strategies; 2 | 3 | /// 4 | /// Strategy invoked during bootstrapping used to define how an 5 | /// entity is created on the service-bus. 6 | /// 7 | public interface IBusEntityCreationStrategy : IBusEntityStrategy 8 | { 9 | /// 10 | /// Invoked when the entity should be created on the service-bus. 11 | /// 12 | /// Future Result. 13 | Task CreateEntity(); 14 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Plugin/Configs/ServiceBusConfig.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.ServiceBus.Plugin.Configs; 2 | 3 | /// 4 | /// Configurations associated with the Azure Service Bus plugin. 5 | /// 6 | public class ServiceBusConfig : IPluginConfig 7 | { 8 | /// 9 | /// Determines if queue and topic namespace entities should automatically 10 | /// be created when the microservice bootstraps. 11 | /// 12 | public bool IsAutoCreateEnabled { get; set; } = false; 13 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/Rpc/RpcReplyException.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.Bus.Rpc; 2 | 3 | /// 4 | /// Exception that is thrown if the RPC reply contains an serialized exception. 5 | /// 6 | public class RpcReplyException : Exception 7 | { 8 | public RpcReplyException(string message) 9 | : base(message) 10 | { 11 | 12 | } 13 | 14 | public RpcReplyException(string message, Exception innerException) 15 | : base(message, innerException) 16 | { 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/DocGeneration/Setup/PluginSetup.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Container; 2 | using NetFusion.Core.TestFixtures.Plugins; 3 | using NetFusion.Web.Rest.Docs.Plugin; 4 | 5 | namespace NetFusion.Web.UnitTests.Rest.DocGeneration.Setup; 6 | 7 | public class PluginSetup 8 | { 9 | public static void WithDefaults(ICompositeContainer container) 10 | { 11 | var hostPlugin = new MockHostPlugin(); 12 | 13 | container.RegisterPlugins(hostPlugin); 14 | container.RegisterPlugin(); 15 | } 16 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/IntegrationTests/RabbitMQ/MockPublisherModule.cs: -------------------------------------------------------------------------------- 1 | using Moq; 2 | using NetFusion.RabbitMQ.Plugin.Modules; 3 | using NetFusion.RabbitMQ.Publisher.Internal; 4 | 5 | namespace IntegrationTests.RabbitMQ 6 | { 7 | using NetFusion.RabbitMQ.Metadata; 8 | 9 | public class MockPublisherModule : PublisherModule 10 | { 11 | protected override IRpcClient CreateRpcClient(ExchangeMeta definition) 12 | { 13 | Mock mockRpcClient = new Mock(); 14 | return mockRpcClient.Object; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Logging/ILogLevelControl.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace NetFusion.Common.Base.Logging; 4 | 5 | /// 6 | /// Interface implemented by a component responsible for changing the log level at runtime. 7 | /// 8 | public interface ILogLevelControl 9 | { 10 | /// 11 | /// Sets the minimum log level at runtime. 12 | /// 13 | /// Log level. 14 | /// The set log level. 15 | string SetMinimumLevel(LogLevel logLevel); 16 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.CodeGen/Plugin/ICodeGenModule.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | using NetFusion.Web.Rest.CodeGen.Plugin.Configs; 3 | 4 | namespace NetFusion.Web.Rest.CodeGen.Plugin; 5 | 6 | /// 7 | /// Plugin module service interface exposing information about the code-generation. 8 | /// 9 | public interface ICodeGenModule : IPluginModuleService 10 | { 11 | /// 12 | /// Reference to the plugin configuration containing code-generation settings. 13 | /// 14 | RestCodeGenConfig CodeGenConfig { get; } 15 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/LinkGeneration/Server/StateModel.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.UnitTests.Rest.LinkGeneration.Server; 2 | 3 | /// 4 | /// Server model returned as a resource to test server-side link generation. 5 | /// 6 | public class StateModel 7 | { 8 | // Model properties used within mappings when specifying resource associated links. 9 | public int Id { get; set; } 10 | public int Value1 { get; set; } 11 | public string Value2 { get; set; } 12 | public int? Value3 { get; set; } 13 | public int Value4 { get; set; } 14 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.TestFixtures/Plugins/MockAppPlugin.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | 3 | namespace NetFusion.Core.TestFixtures.Plugins; 4 | 5 | /// 6 | /// Mock application component plug-in that can be used for testing. 7 | /// The composite container can have multiple associated application 8 | /// components. Components in this type of plug-in are specific 9 | /// to the domain of the application. Domain Entities, Aggregates, 10 | /// and Services such examples. 11 | /// 12 | public class MockAppPlugin() : MockPlugin(PluginTypes.AppPlugin); -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Server/Mappings/IResourceProvider.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Server.Mappings; 2 | 3 | /// 4 | /// Applies the resource metadata to a resource for the given media-type. 5 | /// 6 | public interface IResourceProvider 7 | { 8 | /// 9 | /// Uses the cached REST metadata and applies it to a resource instance. 10 | /// 11 | /// Contains the resource and it associated metadata. 12 | /// Plus any needed services. 13 | void ApplyResourceMeta(ResourceContext context); 14 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Internal/ChannelEntityContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using NetFusion.Core.Bootstrap.Plugins; 3 | using NetFusion.Integration.Bus.Entities; 4 | using NetFusion.Integration.Redis.Plugin; 5 | 6 | namespace NetFusion.Integration.Redis.Internal; 7 | 8 | public class ChannelEntityContext(IPlugin hostPlugin, IServiceProvider serviceProvider) 9 | : BusEntityContext(hostPlugin, serviceProvider) 10 | { 11 | public IConnectionModule ConnectionModule { get; } = serviceProvider.GetRequiredService(); 12 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/DomainEvent.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Types.Contracts; 2 | 3 | namespace NetFusion.Messaging.Types; 4 | 5 | /// 6 | /// Base domain-event that can be published to notify application consumers of an occurrence. 7 | /// Domain-events are used to notify one or more consumers of an occurrence of an event. 8 | /// Often, a command handler will publish domain-events used to notify interested subscribers 9 | /// of state changes made by the handling of the command. 10 | /// 11 | public abstract class DomainEvent : Message, IDomainEvent; -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Routing/IRouteMeta.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Routing; 2 | 3 | /// 4 | /// Allows additional metadata to be associated with a given route. 5 | /// 6 | public interface IRouteMeta; 7 | 8 | /// 9 | /// Allows additional metadata to be associated with a given route. 10 | /// 11 | /// Message type associated with metadata. 12 | public interface IRouteMeta : IRouteMeta 13 | where TMessage : IMessage 14 | { 15 | public Type MessageType => typeof(TMessage); 16 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Resources/EntryPointModel.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Resources; 2 | 3 | /// 4 | /// Model containing information about the Api. 5 | /// 6 | public class EntryPointModel(string version, string apiDocUrl) 7 | { 8 | /// 9 | /// Value indicating the version of the API. 10 | /// 11 | public string Version { get; } = version; 12 | 13 | /// 14 | /// Optional URL to document describing the API. 15 | /// 16 | public string ApiDocUrl { get; } = apiDocUrl; 17 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Internal/ReconnectionEventArgs.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.RabbitMQ.Plugin.Settings; 2 | 3 | namespace NetFusion.Integration.RabbitMQ.Internal 4 | { 5 | /// 6 | /// Event raised when a connection to a broker is reestablished. 7 | /// 8 | public class ReconnectionEventArgs(ConnectionSettings connection) : EventArgs 9 | { 10 | /// 11 | /// Information about the connection. 12 | /// 13 | public ConnectionSettings Connection { get; } = connection; 14 | } 15 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Entities/HalComments.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Entities; 2 | 3 | /// 4 | /// Root entity containing HAL related comments. 5 | /// 6 | public class HalComments 7 | { 8 | /// 9 | /// Comments associated with a resource's embedded items. 10 | /// 11 | public EmbeddedComment[] EmbeddedComments { get; set; } = []; 12 | 13 | /// 14 | /// Comments associated with a resource's link relations. 15 | /// 16 | public RelationComment[] RelationComments { get; set; } = []; 17 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.UnitTests/Entity/DynamicEntity.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Entity; 2 | 3 | namespace NetFusion.Common.UnitTests.Entity; 4 | 5 | public class DynamicEntity : IAttributedEntity 6 | { 7 | public IEntityAttributes Attributes { get; } = new EntityAttributes(); 8 | 9 | public bool IsActive { get; set; } 10 | public int MaxValue { get; set; } 11 | public int MinValue { get; set; } 12 | 13 | public IDictionary AttributeValues 14 | { 15 | get => Attributes.GetValues(); 16 | set => Attributes.SetValues(value); 17 | } 18 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Filters/IPreMessageFilter.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Filters; 2 | 3 | /// 4 | /// Filter executed before the message is dispatched to the consumer. 5 | /// 6 | public interface IPreMessageFilter : IMessageFilter 7 | { 8 | /// 9 | /// Invoked before the message is dispatched to the consumer. 10 | /// 11 | /// The message being dispatched. 12 | /// The task that will be completed when filter is completed. 13 | Task OnPreFilterAsync(IMessage message); 14 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Server/Linking/TemplateUrlLink.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace NetFusion.Web.Rest.Server.Linking; 4 | 5 | /// 6 | /// Represents a link containing an URL template with tokens to be replaced by the calling client. 7 | /// 8 | public class TemplateUrlLink(string relationName, MethodInfo actionMethodInfo) : ResourceLink(relationName) 9 | { 10 | /// 11 | /// The runtime information associated with a selected controller's action. 12 | /// 13 | public MethodInfo ActionMethodInfo { get; } = actionMethodInfo; 14 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/Strategies/IBusEntitySubscriptionStrategy.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.Bus.Strategies; 2 | 3 | /// 4 | /// Strategy invoked during bootstrap to subscribe to a service-bus entity. 5 | /// 6 | public interface IBusEntitySubscriptionStrategy : IBusEntityStrategy 7 | { 8 | /// 9 | /// Called when the strategy should subscribe a message handler 10 | /// to be called when a message arrives on the service-bus entity. 11 | /// 12 | /// Future Result. 13 | Task SubscribeEntity(); 14 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Common/InternetMediaTypes.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Common; 2 | 3 | /// 4 | /// Common HTTP Media types. 5 | /// 6 | public class InternetMediaTypes 7 | { 8 | /// 9 | /// application/json 10 | /// 11 | public const string Json = "application/json"; 12 | 13 | /// 14 | /// application/hal+json 15 | /// 16 | public const string HalJson = "application/hal+json"; 17 | 18 | /// 19 | /// text/plain 20 | /// 21 | public const string PlainText = "text/plain"; 22 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Filters/IPostMessageFilter.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Filters; 2 | 3 | /// 4 | /// Filter executed after the message has been dispatched to the consumer. 5 | /// 6 | public interface IPostMessageFilter : IMessageFilter 7 | { 8 | /// 9 | /// Invoked after the message has been dispatched to the consumer. 10 | /// 11 | /// The message being dispatched. 12 | /// The task that will be completed when execution is completed. 13 | Task OnPostFilterAsync(IMessage message); 14 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Strategies/TestMapStrategyOneToThree.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Services.Mapping; 2 | using NetFusion.Services.UnitTests.Mapping.Entities; 3 | 4 | namespace NetFusion.Services.UnitTests.Mapping.Strategies; 5 | 6 | public class TestMapStrategyOneToThree : MappingStrategy 7 | { 8 | protected override TestMapTypeThree SourceToTarget(TestMapTypeOne source) 9 | { 10 | return new TestMapTypeThree 11 | { 12 | MaxAllowedValue = source.Values.Max(), 13 | Values = source.Values 14 | }; 15 | } 16 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Client/IRestClientFactory.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Client; 2 | 3 | /// 4 | /// Responsible for creating IRestClient instances. 5 | /// 6 | public interface IRestClientFactory 7 | { 8 | /// 9 | /// Creates an IRestClient instance configured by the client application. 10 | /// 11 | /// The name of the configured HttpClient. 12 | /// Instance of REST Client providing additional functionality 13 | /// delegating to an inner HttpClient. 14 | IRestClient CreateClient(string name); 15 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ClientRequests/Server/AddressModel.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Resources; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.ClientRequests.Server; 4 | 5 | /// 6 | /// Server side resource returned by the API Controller under-test. 7 | /// 8 | [Resource("cust-address")] 9 | public class AddressModel 10 | { 11 | public string AddressId { get; set; } 12 | public string CustomerId { get; set; } 13 | public string Street { get; set; } 14 | public string City { get; set; } 15 | public string State { get; set; } 16 | public string ZipCode { get; set; } 17 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Validation/IValidatableType.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Common.Base.Validation; 2 | 3 | /// 4 | /// Implemented by a class to indicate that it should be passed its corresponding 5 | /// validator so validations can be added. 6 | /// 7 | public interface IValidatableType 8 | { 9 | /// 10 | /// Called during the validation process to allow a class instance to apply validations. 11 | /// 12 | /// The validator instance associated with the object being validated. 13 | void Validate(IObjectValidator validator); 14 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Plugin/Modules/ChannelEntityModule.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.Bus.Entities; 2 | using NetFusion.Integration.Redis.Internal; 3 | 4 | namespace NetFusion.Integration.Redis.Plugin.Modules; 5 | 6 | /// 7 | /// Extends the base Bus Entity Module and returns a context 8 | /// specific to Redis Pub/Sub. 9 | /// 10 | public class ChannelEntityModule : BusEntityModuleBase, 11 | IBusEntityModule 12 | { 13 | protected override BusEntityContext CreateContext(IServiceProvider services) => 14 | new ChannelEntityContext(Context.AppHost, services); 15 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/HalComments.json: -------------------------------------------------------------------------------- 1 | { 2 | "embeddedComments": [ 3 | { 4 | "embeddedName": "embedded-child", "parentResourceName": "api.root.model", "childResourceName": "api.embedded.model", 5 | "comments": "exact_match_comment" 6 | }, 7 | { 8 | "embeddedName": "embedded-child-partial", "comments": "partial_match_comment" 9 | } 10 | ], 11 | 12 | "relationComments": [ 13 | { "relationName": "current-child", "resourceName": "resource-with-relation", "comments": "exact_match_comment" }, 14 | { "relationName": "self", "comments": "partial_match_comment" } 15 | ] 16 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/Publisher/Queue.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.AMQP.Publisher.Internal; 2 | using NetFusion.Messaging.Types.Contracts; 3 | 4 | namespace NetFusion.AMQP.Publisher 5 | { 6 | /// 7 | /// Metadata for a queue defined on a host. 8 | /// 9 | /// The type of command associated with queue. 10 | public class Queue : HostItem 11 | where TCommand : ICommand 12 | { 13 | public Queue(string hostName, string name) 14 | : base( hostName, name) 15 | { 16 | 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | // Global using directives 2 | 3 | global using Microsoft.Extensions.DependencyInjection; 4 | global using Microsoft.Extensions.Logging; 5 | global using NetFusion.Common.Base.Logging; 6 | global using NetFusion.Common.Base.Serialization; 7 | global using NetFusion.Common.Extensions.Reflection; 8 | global using NetFusion.Core.Bootstrap.Plugins; 9 | global using NetFusion.Messaging; 10 | global using NetFusion.Messaging.Internal; 11 | global using NetFusion.Messaging.Routing; 12 | global using NetFusion.Messaging.Types.Attributes; 13 | global using NetFusion.Messaging.Types.Contracts; -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Logging/IMessageLogSink.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Logging; 2 | 3 | /// 4 | /// Interface implemented by classes and called when message logs are sent to IMessageLogger. 5 | /// The implementation determines where messages should be written. 6 | /// 7 | public interface IMessageLogSink 8 | { 9 | /// 10 | /// Called by MessageLogger when a message log is recorded. 11 | /// 12 | /// Details about the message. 13 | /// Asynchronous task. 14 | Task WriteLogAsync(MessageLog messageLog); 15 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Routing/ConsumerRoute.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace NetFusion.Messaging.Routing; 4 | 5 | /// 6 | /// Represents a message type and its associated consumer. 7 | /// 8 | internal class ConsumerRoute : MessageRoute 9 | { 10 | public ConsumerRoute(Type messageType, MethodInfo consumer) 11 | : base(messageType) 12 | { 13 | SetConsumer(consumer); 14 | } 15 | 16 | public ConsumerRoute(Type messageType, Type resultType, MethodInfo consumer) 17 | : base(messageType, resultType) 18 | { 19 | SetConsumer(consumer); 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Mapping/Plugin/IMappingModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using NetFusion.Core.Bootstrap.Plugins; 4 | using NetFusion.Services.Mapping.Core; 5 | 6 | namespace NetFusion.Services.Mapping.Plugin; 7 | 8 | /// 9 | /// Interface implemented by a plug-in module responsible for finding all mapping strategies. 10 | /// 11 | public interface IMappingModule : IPluginModuleService 12 | { 13 | /// 14 | /// A lookup keyed by the source type listing all the possible target mappings. 15 | /// 16 | ILookup SourceTypeMappings { get; } 17 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Strategies/TestMappingStrategyFactory.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Services.Mapping; 2 | using NetFusion.Services.UnitTests.Mapping.Entities; 3 | 4 | namespace NetFusion.Services.UnitTests.Mapping.Strategies; 5 | 6 | public class TestMappingStrategyFactory : IMappingStrategyFactory 7 | { 8 | public IEnumerable GetStrategies() 9 | { 10 | yield return DelegateMap.Map((TestMapTypeOne s) => new TestMapTypeTwo 11 | { 12 | Sum = s.Values.Sum(), 13 | Min = s.Values.Min(), 14 | Max = s.Values.Max() 15 | }); 16 | } 17 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Strategies/TestMapStrategyOneToTwo.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Services.Mapping; 2 | using NetFusion.Services.UnitTests.Mapping.Entities; 3 | 4 | namespace NetFusion.Services.UnitTests.Mapping.Strategies; 5 | 6 | public class TestMapStrategyOneToTwo : MappingStrategy 7 | { 8 | protected override TestMapTypeTwo SourceToTarget(TestMapTypeOne source) 9 | { 10 | return new TestMapTypeTwo 11 | { 12 | Sum = source.Values.Sum(), 13 | Min = source.Values.Min(), 14 | Max = source.Values.Max() 15 | }; 16 | } 17 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/Contracts/IQuery.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Types.Contracts; 2 | 3 | /// 4 | /// Represents a query request that can be dispatched to a consumer. 5 | /// 6 | public interface IQuery : IMessage; 7 | 8 | /// 9 | /// Represents a query request that can be dispatched to a consumer. 10 | /// 11 | /// The type of the result expected by the query. 12 | public interface IQuery : IQuery 13 | { 14 | /// 15 | /// The result of the query's execution. 16 | /// 17 | TResult Result { get; set; } 18 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/Logging/Mocks/LoggingSinks.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Logging; 2 | 3 | namespace NetFusion.Messaging.UnitTests.Logging.Mocks; 4 | 5 | public class MockLoggingSink : IMessageLogSink 6 | { 7 | private readonly List _receivedLogs = []; 8 | 9 | public MockLoggingSink() 10 | { 11 | ReceivedLogs = _receivedLogs; 12 | } 13 | 14 | public IReadOnlyCollection ReceivedLogs { get; } 15 | 16 | public Task WriteLogAsync(MessageLog messageLog) 17 | { 18 | _receivedLogs.Add(messageLog); 19 | return Task.CompletedTask; 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Container; 2 | using NetFusion.Core.TestFixtures.Plugins; 3 | using NetFusion.Messaging.Plugin; 4 | 5 | namespace NetFusion.Messaging.UnitTests; 6 | 7 | public static class TestSetup 8 | { 9 | public static void WithEventHandler(ICompositeContainer container) 10 | { 11 | var appPlugin = new MockAppPlugin(); 12 | appPlugin.AddModule(); 13 | 14 | container.RegisterPlugin(); 15 | container.RegisterPlugins(appPlugin); 16 | container.RegisterPlugin(); 17 | } 18 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/DocGeneration/Server/TestRequestModels.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Resources; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.DocGeneration.Server; 4 | 5 | /// 6 | /// Example mode populated from the body of a request. 7 | /// 8 | [Resource("TestRequest")] 9 | public class TestRequestModel 10 | { 11 | /// 12 | /// The first name read from the request body. 13 | /// 14 | public string FirstName { get; set; } 15 | 16 | /// 17 | /// The last name read from the request body. 18 | /// 19 | public string LastName { get; set; } 20 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Server/Plugin/Modules/ConcurrencyModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using NetFusion.Common.Base.Entity; 3 | using NetFusion.Core.Bootstrap.Plugins; 4 | using NetFusion.Web.Rest.Server.Concurrency; 5 | 6 | namespace NetFusion.Web.Rest.Server.Plugin.Modules; 7 | 8 | public class ConcurrencyModule : PluginModule 9 | { 10 | public override void RegisterServices(IServiceCollection services) 11 | { 12 | services.AddScoped(); 13 | 14 | services.AddControllers(options => 15 | { 16 | options.Filters.Add(); 17 | }); 18 | } 19 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web/Plugin/Modules/ApiMetadataModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using NetFusion.Core.Bootstrap.Plugins; 3 | using NetFusion.Web.Metadata; 4 | using NetFusion.Web.Metadata.Core; 5 | 6 | namespace NetFusion.Web.Plugin.Modules; 7 | 8 | /// 9 | /// Plugin module that registers a service used to query ASP.NET controller action metadata. 10 | /// 11 | public class ApiMetadataModule : PluginModule 12 | { 13 | public override void RegisterServices(IServiceCollection services) 14 | { 15 | services.AddMvc(); 16 | services.AddSingleton(); 17 | } 18 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Health/Mocks/HealthCheckModuleOne.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Health; 2 | using NetFusion.Core.Bootstrap.Plugins; 3 | 4 | namespace NetFusion.Core.UnitTests.Health.Mocks; 5 | 6 | public class HealthCheckModuleOne : PluginModule, 7 | IModuleHealthCheckProvider 8 | { 9 | public HealthCheckStatusType HealthCheckStatus { get; set; } = HealthCheckStatusType.Healthy; 10 | 11 | public Task CheckModuleAspectsAsync(ModuleHealthCheck healthCheck) 12 | { 13 | healthCheck.RecordAspect(HealthAspectCheck.For("ModuleOneAspect", "ModuleOneValue", HealthCheckStatus)); 14 | return Task.CompletedTask; 15 | } 16 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Health/Mocks/HealthCheckModuleTwo.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Health; 2 | using NetFusion.Core.Bootstrap.Plugins; 3 | 4 | namespace NetFusion.Core.UnitTests.Health.Mocks; 5 | 6 | public class HealthCheckModuleTwo : PluginModule, 7 | IModuleHealthCheckProvider 8 | { 9 | public HealthCheckStatusType HealthCheckStatus { get; set; } = HealthCheckStatusType.Healthy; 10 | 11 | public Task CheckModuleAspectsAsync(ModuleHealthCheck healthCheck) 12 | { 13 | healthCheck.RecordAspect(HealthAspectCheck.For("ModuleTwoAspect", "ModuleTwoValue", HealthCheckStatus)); 14 | return Task.CompletedTask; 15 | } 16 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/Messaging/Logging/Mocks/LoggingSinks.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Logging; 2 | 3 | namespace NetFusion.Messaging.UnitTests.Messaging.Logging.Mocks; 4 | 5 | public class MockLoggingSink : IMessageLogSink 6 | { 7 | private readonly List _receivedLogs = []; 8 | 9 | public MockLoggingSink() 10 | { 11 | ReceivedLogs = _receivedLogs; 12 | } 13 | 14 | public IReadOnlyCollection ReceivedLogs { get; } 15 | 16 | public Task WriteLogAsync(MessageLog messageLog) 17 | { 18 | _receivedLogs.Add(messageLog); 19 | return Task.CompletedTask; 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Server/Hal/Core/HalResourceMeta.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Server.Meta; 2 | 3 | namespace NetFusion.Web.Rest.Server.Hal.Core; 4 | 5 | /// 6 | /// HAL resource metadata for a given model type. 7 | /// 8 | /// The type of model associated with resource. 9 | public class HalResourceMeta : ResourceMeta> 10 | where TModel : class 11 | { 12 | // ** Addition needed HAL specific methods to record any metadata can be added. 13 | // ** This class derives from ResourceMeta which allows adding links to the 14 | // ** specified resource type. 15 | } -------------------------------------------------------------------------------- /netfusion/build/common.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | NetFusion Contributors 4 | NetFusion 5 | https://github.com/grecosoft/NetFusion/wiki 6 | https://github.com/grecosoft/NetFusion 7 | http://www.opensource.org/licenses/mit-license.php 8 | git 9 | true 10 | netfusion.png 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.UnitTests/Extensions/TypeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using FluentAssertions; 3 | using NetFusion.Common.Extensions.Types; 4 | 5 | namespace NetFusion.Common.UnitTests.Extensions; 6 | 7 | public class TypeExtensions 8 | { 9 | [Fact] 10 | public void CanMapCSharpType_To_JavascriptType() 11 | { 12 | "Test".GetType().GetJsTypeName().Should().Be("String"); 13 | DateTime.UtcNow.GetType().GetJsTypeName().Should().Be("Date"); 14 | } 15 | 16 | [Fact] 17 | public void IfUnknownCSharpType_ObjectJavascript() 18 | { 19 | new StringBuilder().GetType().GetJsTypeName().Should().Be("Object"); 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Bootstrap/Mocks/ServiceRegistrationTests.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Core.UnitTests.Bootstrap.Mocks; 2 | 3 | public class ServiceRegistrationTests 4 | { 5 | [Fact] 6 | public void DefaultServices_OverridenBy_OtherPlugins() 7 | { 8 | 9 | } 10 | 11 | [Fact] 12 | public void CoreServices_OverridenBy_ApplicationPlugins() 13 | { 14 | 15 | } 16 | 17 | [Fact] 18 | public void ApplicationServices_OverridenBy_HostServices() 19 | { 20 | 21 | } 22 | 23 | [Fact] 24 | public void RegisteredServices_Overriden_WhenComposing() 25 | { 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Core/ITypeCommentService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NetFusion.Web.Rest.Docs.Models; 3 | 4 | namespace NetFusion.Web.Rest.Docs.Core; 5 | 6 | /// 7 | /// Service responsible for building documentation for a specific type based on an underlying source. 8 | /// 9 | public interface ITypeCommentService 10 | { 11 | /// 12 | /// Returns documentation for a resource type. 13 | /// 14 | /// The type of the resource to document. 15 | /// Model containing documentation for the resource. 16 | ApiResourceDoc GetResourceDoc(Type resourceType); 17 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Scripting/ScriptPredicate.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Common.Base.Scripting; 2 | 3 | /// 4 | /// Properties describing a script to be executed and the value of an entity 5 | /// attribute containing the result of the Boolean expression. 6 | /// 7 | /// The name of the script that should be executed against a source object 8 | /// to determine if it meets the criteria of the expression. 9 | /// The entity's Boolean attribute that determines if the source object 10 | /// matches the criteria of the script. 11 | public record ScriptPredicate(string ScriptName, string AttributeName); -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Enrichers/IMessageEnricher.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Enrichers; 2 | 3 | /// 4 | /// Types implementing this interface are registered within the application's 5 | /// bootstrap configuration and called for each published message. The role 6 | /// of an enricher is to added key/value pairs to the message. 7 | /// 8 | public interface IMessageEnricher 9 | { 10 | /// 11 | /// Implementation should add a key/value pair to the message. 12 | /// 13 | /// The message to enrich. 14 | /// Future Result 15 | Task EnrichAsync(IMessage message); 16 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | // Global using directives 2 | 3 | global using Microsoft.Extensions.DependencyInjection; 4 | global using Microsoft.Extensions.Logging; 5 | global using NetFusion.Common.Base.Logging; 6 | global using NetFusion.Common.Base.Serialization; 7 | global using NetFusion.Common.Extensions.Collections; 8 | global using NetFusion.Common.Extensions.Reflection; 9 | global using NetFusion.Core.Bootstrap.Plugins; 10 | global using NetFusion.Messaging; 11 | global using NetFusion.Messaging.Internal; 12 | global using NetFusion.Messaging.Routing; 13 | global using NetFusion.Messaging.Types.Attributes; 14 | global using NetFusion.Messaging.Types.Contracts; -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Rpc/Metadata/RpcQueueMeta.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.ServiceBus.Rpc.Metadata; 2 | 3 | /// 4 | /// Metadata used to define a queue on which a microservice receives 5 | /// RPC style of messages. 6 | /// 7 | public class RpcQueueMeta(string queueName) : IRpcQueueMeta 8 | { 9 | public string QueueName { get; } = queueName; 10 | public RpcProcessingOptions ProcessingOptions { get; } = new(); 11 | 12 | public TimeSpan? LockDuration { get; set; } 13 | public int? MaxDeliveryCount { get; set; } 14 | public long? MaxSizeInMegabytes { get; set; } 15 | public TimeSpan? DefaultMessageTimeToLive { get; set; } 16 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Roslyn/DynamicEntity.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Entity; 2 | 3 | namespace NetFusion.Services.UnitTests.Roslyn; 4 | 5 | public class DynamicEntity : IAttributedEntity 6 | { 7 | public IEntityAttributes Attributes { get; } 8 | 9 | public DynamicEntity() 10 | { 11 | Attributes = new EntityAttributes(); 12 | } 13 | 14 | public bool IsActive { get; set; } 15 | public int MaxValue { get; set; } 16 | public int MinValue { get; set; } 17 | 18 | public IDictionary AttributeValues 19 | { 20 | get => Attributes.GetValues(); 21 | set => Attributes.SetValues(value); 22 | } 23 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Validation/ValidationService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetFusion.Common.Base.Validation; 4 | 5 | /// 6 | /// Service that delegates to ICompositeApp to create an instance 7 | /// of the host provided IObjectValidator used for validation. 8 | /// 9 | public class ValidationService : IValidationService 10 | { 11 | public ValidationResultSet Validate(object obj) 12 | { 13 | if (obj == null) throw new ArgumentNullException(nameof(obj), 14 | "Object to validate cannot be null."); 15 | 16 | ObjectValidator validator = new ObjectValidator(obj); 17 | return validator.Validate(); 18 | } 19 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Bootstrap/Health/IModuleHealthCheckProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace NetFusion.Core.Bootstrap.Health; 4 | 5 | /// 6 | /// Implemented by any IPluginModule derive class to participate in 7 | /// determining the overall health of the composite-application. 8 | /// 9 | public interface IModuleHealthCheckProvider 10 | { 11 | /// 12 | /// Populates a module health-check by recording the health of specific 13 | /// aspects managed by the module. 14 | /// 15 | /// Health check to be populated. 16 | Task CheckModuleAspectsAsync(ModuleHealthCheck healthCheck); 17 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Core/IDocBuilder.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Metadata; 2 | using NetFusion.Web.Rest.Docs.Models; 3 | 4 | namespace NetFusion.Web.Rest.Docs.Core; 5 | 6 | /// 7 | /// Contract for a component responsible for building an action documentation 8 | /// model from a WebApi action method metadata. 9 | /// 10 | public interface IDocBuilder 11 | { 12 | /// 13 | /// Creates an action document from associated metadata. 14 | /// 15 | /// The metadata describing the action method. 16 | /// The constructed model. 17 | ApiActionDoc BuildActionDoc(ApiActionMeta actionMeta); 18 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ClientRequests/Server/CustomerResourceMap.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Common; 2 | using NetFusion.Web.Rest.Server.Hal; 3 | 4 | namespace NetFusion.Web.UnitTests.Rest.ClientRequests.Server; 5 | 6 | /// 7 | /// Resource mapping class used by the unit-tests that will be discovered 8 | /// by the NetFusion container REST/HAL Plug-in. 9 | /// 10 | public class CustomerResourceMap : HalResourceMap 11 | { 12 | protected override void OnBuildResourceMap() 13 | { 14 | Map() 15 | .LinkMeta(meta => 16 | meta.Url(RelationTypes.Self, (c, r) => c.GetCustomer(r.CustomerId))); 17 | } 18 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/DocGeneration/Server/DocResourceMap.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Server.Hal; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.DocGeneration.Server; 4 | 5 | public class DocResourceMap : HalResourceMap 6 | { 7 | protected override void OnBuildResourceMap() 8 | { 9 | Map() 10 | .LinkMeta( 11 | meta => meta.Url("relation-1", (c, r) => c.GetResourceDetails(r.ModelId, r.VersionNumber))); 12 | 13 | Map() 14 | .LinkMeta( 15 | meta => meta.Url("relation-2", (c, r) => c.GetEmbeddedResourceDetails(r.ModelId))); 16 | } 17 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Bootstrap/Plugins/PluginSummary.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Core.Bootstrap.Plugins; 2 | 3 | /// 4 | /// Read-only class providing a summary information for a plugin. 5 | /// 6 | public class PluginSummary 7 | { 8 | public string PluginId { get; } 9 | public string Name { get; } 10 | public string AssemblyName { get; } 11 | public string AssemblyVersion { get; } 12 | 13 | public PluginSummary(IPlugin plugin) 14 | { 15 | System.ArgumentNullException.ThrowIfNull(plugin); 16 | 17 | PluginId = plugin.PluginId; 18 | Name = plugin.Name; 19 | AssemblyName = plugin.AssemblyName; 20 | AssemblyVersion = plugin.AssemblyVersion; 21 | } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Client/IRestClientService.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Client; 2 | 3 | /// 4 | /// Provides a service that delegates to IRequestClientFactory and provides 5 | /// caching of the underlying HttpClient and other higher level methods. 6 | /// 7 | public interface IRestClientService 8 | { 9 | /// 10 | /// Returns a reference to a configured named client for making 11 | /// HTTP requests. 12 | /// 13 | /// The name of the configured client. 14 | /// Reference to the request client. The same instance 15 | /// of the IRestClient is returned based on name. 16 | IRestClient GetClient(string name); 17 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Validation/IValidationService.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Common.Base.Validation; 2 | 3 | /// 4 | /// Service for validating objects using the host provided IObjectValidator instance. 5 | /// If the host does not provided a IObjectValidator implementation, a version based 6 | /// on Microsoft's Data Annotations is used. 7 | /// 8 | public interface IValidationService 9 | { 10 | /// 11 | /// Validates the object and all if its children and returns a flattened list 12 | /// containing objects with validations. 13 | /// 14 | /// Result set containing all objects with resulting validations. 15 | ValidationResultSet Validate(object obj); 16 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Internal/CachedConnection.cs: -------------------------------------------------------------------------------- 1 | using StackExchange.Redis; 2 | 3 | namespace NetFusion.Integration.Redis.Internal 4 | { 5 | /// 6 | /// Contains a reference to a Redis connection and the configuration 7 | /// options from which it was created. 8 | /// 9 | public class CachedConnection( 10 | ConfigurationOptions configuration, 11 | ConnectionMultiplexer connection) 12 | { 13 | public ConfigurationOptions Configuration { get; } = configuration ?? throw new ArgumentNullException(nameof(configuration)); 14 | public ConnectionMultiplexer Connection { get; } = connection ?? throw new ArgumentNullException(nameof(connection)); 15 | } 16 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Namespaces/MessageProperties.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using Azure.Messaging.ServiceBus; 3 | using NetFusion.Integration.Bus; 4 | 5 | namespace NetFusion.Integration.ServiceBus.Namespaces; 6 | 7 | /// 8 | /// Reading and parsing of message properties. 9 | /// 10 | internal static class MessageProperties 11 | { 12 | public static bool TryParseReplyTo(ProcessMessageEventArgs args, 13 | [MaybeNullWhen(false)]out string busName, [MaybeNullWhen(false)]out string queueName) 14 | { 15 | ArgumentNullException.ThrowIfNull(args); 16 | return MessageExtensions.TryParseReplyTo(args.Message.ReplyTo, out busName, out queueName); 17 | } 18 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/Strategies/IBusEntityStrategy.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.Bus.Entities; 2 | 3 | namespace NetFusion.Integration.Bus.Strategies; 4 | 5 | /// 6 | /// Base interface form which all strategies derive. 7 | /// 8 | public interface IBusEntityStrategy 9 | { 10 | /// 11 | /// Reference to the entity associated with the strategy. 12 | /// 13 | public BusEntity BusEntity { get; } 14 | 15 | /// 16 | /// Called during bootstrapping to associate a context with the strategy. 17 | /// 18 | /// The context containing cross-cutting services. 19 | void SetContext(BusEntityContext context); 20 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.UnitTests/RabbitMQ/Mocks/TestRabbitBusModule.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | using NetFusion.Integration.RabbitMQ.Bus; 3 | using NetFusion.Integration.RabbitMQ.Internal; 4 | using NetFusion.Integration.RabbitMQ.Plugin; 5 | using NetFusion.Integration.RabbitMQ.Plugin.Configs; 6 | 7 | namespace NetFusion.Integration.UnitTests.RabbitMQ.Mocks; 8 | 9 | public class TestRabbitBusModule : PluginModule, 10 | IBusModule 11 | { 12 | public RabbitMqConfig RabbitMqConfig { get; } = new(); 13 | 14 | public IBusConnection GetConnection(string busName) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | 19 | public event EventHandler? Reconnection; 20 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Strategies/TestMapStrategyThreeToTwo.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Services.Mapping; 2 | using NetFusion.Services.UnitTests.Mapping.Entities; 3 | 4 | namespace NetFusion.Services.UnitTests.Mapping.Strategies; 5 | 6 | public class TestMapStrategyThreeToTwo : MappingStrategy 7 | { 8 | protected override TestMapTypeTwo SourceToTarget(TestMapTypeThree source) 9 | { 10 | var validValues = source.Values.Where(v => v <= source.MaxAllowedValue).ToArray(); 11 | 12 | return new TestMapTypeTwo 13 | { 14 | Min = validValues.Min(), 15 | Max = validValues.Max(), 16 | Sum = validValues.Sum() 17 | }; 18 | } 19 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Client/Core/RestClientService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | 4 | namespace NetFusion.Web.Rest.Client.Core; 5 | 6 | /// 7 | /// Provides caching an other high-level services. 8 | /// 9 | public class RestClientService(IRestClientFactory clientFactory) : IRestClientService 10 | { 11 | private readonly ConcurrentDictionary _restClients = new(); 12 | 13 | private readonly IRestClientFactory _clientFactory = clientFactory ?? 14 | throw new ArgumentNullException(nameof(clientFactory)); 15 | 16 | public IRestClient GetClient(string name) 17 | { 18 | return _restClients.GetOrAdd(name, _clientFactory.CreateClient); 19 | } 20 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Internal/IBatchMessagePublisher.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Internal; 2 | 3 | /// 4 | /// Optional interface implemented by a message publisher supporting 5 | /// sending batches of domain-events. 6 | /// 7 | public interface IBatchMessagePublisher 8 | { 9 | /// 10 | /// Publishes a list of domain-events in batch. 11 | /// 12 | /// List of domain-events to be published. 13 | /// Cancellation token used to cancel async task. 14 | /// Future Task Result. 15 | Task PublicDomainEventsAsync(IEnumerable domainEvents, CancellationToken cancellationToken); 16 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Resources/ResourceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetFusion.Web.Rest.Resources; 4 | 5 | /// 6 | /// Used to map a string name to a given resource model. This attribute 7 | /// specifies a name used to identity the resource to clients consuming 8 | /// the REST Api. 9 | /// 10 | [AttributeUsage(AttributeTargets.Class)] 11 | public class ResourceAttribute : Attribute 12 | { 13 | public string ResourceName { get; } 14 | 15 | public ResourceAttribute(string resourceName) 16 | { 17 | if (string.IsNullOrWhiteSpace(resourceName)) 18 | throw new ArgumentException("Resource name not specified.", nameof(resourceName)); 19 | 20 | ResourceName = resourceName; 21 | } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Entity/IAttributedEntity.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NetFusion.Common.Base.Entity; 4 | 5 | /// 6 | /// Identifies an entity having a set of key/value attributes that 7 | /// can be accessed dynamically at runtime. 8 | /// 9 | public interface IAttributedEntity 10 | { 11 | /// 12 | /// Reference to object used to manage an entity's dynamic attributes. 13 | /// 14 | IEntityAttributes Attributes { get; } 15 | 16 | /// 17 | /// A dictionary of the key value pairs associated with the entity 18 | /// in which the dynamic properties are stored. 19 | /// 20 | IDictionary AttributeValues { get; set; } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/DomainEvents/Mocks/DomainEvents.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Types; 2 | 3 | namespace NetFusion.Messaging.UnitTests.DomainEvents.Mocks; 4 | 5 | // --------------------- [Domain Events] --------------------- 6 | 7 | public class MockDomainEvent : DomainEvent 8 | { 9 | public List ThrowInHandlers { get; } = new(); 10 | } 11 | 12 | public class MockDomainEventTwo : DomainEvent; 13 | 14 | // ------------------- [Derived Domain Events] ------------------ 15 | 16 | public class MockBaseDomainEvent : DomainEvent; 17 | 18 | public class MockDerivedDomainEvent : MockBaseDomainEvent; 19 | 20 | public class MockRuleDomainEvent : DomainEvent 21 | { 22 | public int RuleTestValue { get; set; } = -1; 23 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Common/NetFusion.Web.Common.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | NetFusion.Web.Common 13 | NetFusion REST Shared Implementations 14 | Contains implementations shared between the client and server. 15 | netfusion;plugin;rest;hal;http;client; 16 | 17 | -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/IBusRouter.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | using NetFusion.Integration.Bus.Entities; 3 | 4 | namespace NetFusion.Integration.Bus; 5 | 6 | /// 7 | /// Responsible for defining the service-bus related entities 8 | /// and how messages are routed. 9 | /// 10 | public interface IBusRouter : IPluginKnownType 11 | { 12 | /// 13 | /// The name of the service-bus to which the entities are associated. 14 | /// 15 | public string BusName { get; } 16 | 17 | /// 18 | /// Returns the entities associated with the service-bus. 19 | /// 20 | /// List of bus entities. 21 | IEnumerable GetBusEntities(); 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Plugin/Modules/RedisModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using NetFusion.Core.Bootstrap.Plugins; 3 | using NetFusion.Integration.Redis.Internal; 4 | using NetFusion.Integration.Redis.Subscriber; 5 | 6 | namespace NetFusion.Integration.Redis.Plugin.Modules 7 | { 8 | /// 9 | /// Module containing additional Redis component registrations. 10 | /// 11 | public class RedisModule : PluginModule 12 | { 13 | public override void RegisterServices(IServiceCollection services) 14 | { 15 | services.AddSingleton(); 16 | services.AddSingleton(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Models/ApiResponseDoc.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Models; 2 | 3 | /// 4 | /// Model representing the status code returned from a Web Api method a 5 | /// nd the optional associated response resource. 6 | /// 7 | public class ApiResponseDoc 8 | { 9 | /// 10 | /// The HTTP response status code associated with the response. 11 | /// 12 | public int Status { get; set; } 13 | 14 | /// 15 | /// The documentation associated with the resource that will 16 | /// be returned for the status code. This property will be 17 | /// null if a resource is not returned for the status code. 18 | /// 19 | public ApiResourceDoc ResourceDoc { get; set; } 20 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Plugin/IDocModule.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | using NetFusion.Web.Rest.Docs.Entities; 3 | using NetFusion.Web.Rest.Docs.Plugin.Configs; 4 | 5 | namespace NetFusion.Web.Rest.Docs.Plugin; 6 | 7 | /// 8 | /// Plugin module responsible for configuring and registering 9 | /// services required to provide REST Api documentation. 10 | /// 11 | public interface IDocModule : IPluginModuleService 12 | { 13 | /// 14 | /// Reference to the REST Documentation configuration settings. 15 | /// 16 | RestDocConfig RestDocConfig { get; } 17 | 18 | /// 19 | /// Reference to HAL specific comments. 20 | /// 21 | HalComments HalComments { get; } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Subscriber/ChannelSubscriberEntity.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.Bus.Entities; 2 | using NetFusion.Integration.Redis.Subscriber.Strategies; 3 | using NetFusion.Messaging.Internal; 4 | 5 | namespace NetFusion.Integration.Redis.Subscriber; 6 | 7 | public class ChannelSubscriberEntity : BusEntity 8 | { 9 | public MessageDispatcher Dispatcher { get; } 10 | 11 | public ChannelSubscriberEntity(string busName, string channelName, MessageDispatcher dispatcher) : 12 | base(busName, channelName) 13 | { 14 | Dispatcher = dispatcher; 15 | 16 | AddStrategies(new ChannelSubscriberStrategy(this)); 17 | } 18 | 19 | public override IEnumerable Dispatchers => new[] { Dispatcher }; 20 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Bootstrap/Health/HealthCheckResultType.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Core.Bootstrap.Health; 2 | 3 | /// 4 | /// Indicates the health status for specific items used in determining 5 | /// the overall status of the composite-application. 6 | /// 7 | public enum HealthCheckStatusType 8 | { 9 | /// 10 | /// All plugins are operational. 11 | /// 12 | Healthy = 1, 13 | 14 | /// 15 | /// Contains plugins that are not operational but can till process submitted requests. 16 | /// 17 | Degraded = 2, 18 | 19 | /// 20 | /// Plugins required to provide the application's core functionality are not operational. 21 | /// 22 | Unhealthy = 3 23 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Core/Descriptions/IEmbeddedDescription.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Docs.Models; 2 | 3 | namespace NetFusion.Web.Rest.Docs.Core.Descriptions; 4 | 5 | /// 6 | /// Interface implemented by a class responsible for describing 7 | /// an embedded resource returned by a controller's action method. 8 | /// 9 | public interface IEmbeddedDescription : IDocDescription 10 | { 11 | /// 12 | /// Adds documentation to an embedded document. 13 | /// 14 | /// The embedded documentation model to describe. 15 | /// The attribute from which the embedded document was created. 16 | void Describe(ApiEmbeddedDoc embeddedDoc, EmbeddedResourceAttribute attribute); 17 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/Contracts/IMessageWithResult.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Types.Contracts; 2 | 3 | /// 4 | /// Interface used internally to access and set the result of a message. 5 | /// 6 | public interface IMessageWithResult 7 | { 8 | /// 9 | /// The optional result of the command. 10 | /// 11 | object? MessageResult { get; set; } 12 | 13 | /// 14 | /// The type of the result associated with the command. 15 | /// 16 | Type DeclaredResultType { get; } 17 | 18 | /// 19 | /// Sets the optional result associated with the message. 20 | /// 21 | /// Associated result. 22 | void SetResult(object? result); 23 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Core/Descriptions/IActionDescription.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Metadata; 2 | using NetFusion.Web.Rest.Docs.Models; 3 | 4 | namespace NetFusion.Web.Rest.Docs.Core.Descriptions; 5 | 6 | /// 7 | /// Interface implemented by a class responsible for describing 8 | /// a controller's action method. 9 | /// 10 | public interface IActionDescription : IDocDescription 11 | { 12 | /// 13 | /// Called to add descriptions to the specified action document. 14 | /// 15 | /// The action document to describe. 16 | /// The associated action metadata used 17 | /// to query related information. 18 | void Describe(ApiActionDoc actionDoc, ApiActionMeta actionMeta); 19 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Entities/RelationComment.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Entities; 2 | 3 | /// 4 | /// Comments associated with a resource's linked relation. 5 | /// 6 | public class RelationComment 7 | { 8 | /// 9 | /// The name of the relation specified when adding a link to a resource. 10 | /// 11 | public string RelationName { get; set; } 12 | 13 | /// 14 | /// The optional resource name identifying the resource containing the named relation. 15 | /// 16 | public string ResourceName { get; set; } 17 | 18 | /// 19 | /// The comments describing how the relation applies to the resource. 20 | /// 21 | public string Comments { get; set; } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Plugin/Settings/HostSettings.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace NetFusion.Integration.RabbitMQ.Plugin.Settings 4 | { 5 | /// 6 | /// Settings for a host associated with a specific bus connection. 7 | /// 8 | public class HostSettings 9 | { 10 | /// 11 | /// The name of the host computer running RabbitMQ. 12 | /// 13 | [Required(AllowEmptyStrings = false, ErrorMessage = "HostName Required")] 14 | public string HostName { get; set; } = string.Empty; 15 | 16 | /// 17 | /// The connection port to use. Defaults to 5672. 18 | /// 19 | public ushort Port { get; set; } = 5672; 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/IntegrationTypes.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging; 2 | 3 | /// 4 | /// Determines the scope to which a given message publisher 5 | /// sends domain events to interested subscribers. 6 | /// 7 | public enum IntegrationTypes 8 | { 9 | /// 10 | /// Used to specify all integration types apply. 11 | /// 12 | All = 0, 13 | 14 | /// 15 | /// The publisher dispatches the event to subscribers located 16 | /// within the same process as the publisher. 17 | /// 18 | Internal = 1, 19 | 20 | /// 21 | /// The publisher dispatches the event to subscribers located 22 | /// external to the publisher via a central message bus. 23 | /// 24 | External = 2 25 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/DocGeneration/Server/TestResponseModels.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Resources; 2 | 3 | namespace NetFusion.Web.UnitTests.Rest.DocGeneration.Server; 4 | 5 | public class TestResponseModel; 6 | 7 | public class TestCreatedResponseModel; 8 | 9 | [Resource("api.sample.model")] 10 | public class ModelWithExposedName; 11 | 12 | public class ModelWithoutExposedName; 13 | 14 | [Resource("api.root.model")] 15 | public class RootResponseModel; 16 | 17 | [Resource("api.embedded.model")] 18 | public class EmbeddedChildModel; 19 | 20 | public class ModelWithResourceLinks 21 | { 22 | public string ModelId { get; set; } 23 | public int VersionNumber { get; set; } 24 | } 25 | 26 | public class EmbeddedModelWithResourceLinks 27 | { 28 | public string ModelId { get; set; } 29 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Plugin/RestDocExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | 3 | namespace NetFusion.Web.Rest.Docs.Plugin; 4 | 5 | /// 6 | /// Application builder configuration extensions. 7 | /// 8 | public static class RestDocExtensions 9 | { 10 | /// 11 | /// Adds the middleware exposing an endpoint used to query WebApi documentation. 12 | /// 13 | /// The builder to be configured. 14 | /// Reference to the builder. 15 | public static IApplicationBuilder UseRestDocs(this IApplicationBuilder builder) 16 | { 17 | System.ArgumentNullException.ThrowIfNull(builder); 18 | 19 | builder.UseMiddleware(); 20 | return builder; 21 | } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/IQueueResponseService.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.ServiceBus; 2 | 3 | /// 4 | /// Service allowing a correlated reply to a previously received message. 5 | /// 6 | public interface IQueueResponseService 7 | { 8 | /// 9 | /// Sends a response to the originating request. An exception is thrown if the message 10 | /// properties are missing any values required from the original sender to correlate the 11 | /// response. 12 | /// 13 | /// The command originally received. 14 | /// The response corresponding to the request. 15 | /// Future Result 16 | Task RespondToSenderAsync(ICommand command, ICommand response); 17 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web/Metadata/ApiResponseMeta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetFusion.Web.Metadata; 4 | 5 | /// 6 | /// Information about a WebApi method response. 7 | /// 8 | public class ApiResponseMeta 9 | { 10 | /// 11 | /// The HTTP status code associated with the response. 12 | /// 13 | public int Status { get; } 14 | 15 | /// 16 | /// The optional model type associated with the HTTP status code. 17 | /// 18 | public Type? ModelType { get; set; } 19 | 20 | public ApiResponseMeta(int status, Type modelType) 21 | { 22 | ArgumentNullException.ThrowIfNull(modelType); 23 | 24 | Status = status; 25 | ModelType = modelType == typeof(void) ? null : modelType; 26 | } 27 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/Contracts/ICommand.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Types.Contracts; 2 | 3 | /// 4 | /// Represents a message that can have one and only one consumer. A command expresses 5 | /// an action that is to take place resulting in a change to an application's state. 6 | /// 7 | public interface ICommand : IMessage; 8 | 9 | /// 10 | /// Represents a message that can have one and only one consumer. The handling consumer 11 | /// can associate a result after processing the message. This type of message tells the 12 | /// consumer to take an action. 13 | /// 14 | /// The response set by the consumer that processed the message. 15 | public interface ICommand : ICommand 16 | { 17 | TResult Result { get; set; } 18 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Core/Descriptions/IResponseDescription.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Metadata; 2 | using NetFusion.Web.Rest.Docs.Models; 3 | 4 | namespace NetFusion.Web.Rest.Docs.Core.Descriptions; 5 | 6 | /// 7 | /// Interface implemented by a class responsible for describing 8 | /// a controller's action responses. 9 | /// 10 | public interface IResponseDescription : IDocDescription 11 | { 12 | /// 13 | /// Called to add documentation to the response document model. 14 | /// 15 | /// The response document to describe. 16 | /// The associated document metadata from which 17 | /// the document model was created. 18 | void Describe(ApiResponseDoc responseDoc, ApiResponseMeta responseMeta); 19 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/Setup/NullUnitTestService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.AspNetCore.Http; 4 | using NetFusion.Web.Rest.Resources; 5 | using NetFusion.Web.UnitTests.Mocks; 6 | using NetFusion.Web.UnitTests.Rest.ClientRequests.Server; 7 | 8 | namespace NetFusion.Web.UnitTests.Rest.Setup; 9 | 10 | public class NullUnitTestService : IMockedService 11 | { 12 | public IEnumerable Customers { get; set; } = Array.Empty(); 13 | 14 | public HalResource ServerReceivedResource { get; set; } 15 | 16 | public bool TriggerServerSideException { get; set; } = false; 17 | public int ReturnsStatusCode { get; set; } = StatusCodes.Status200OK; 18 | 19 | public IEnumerable GetResources() 20 | { 21 | return new T[] { }; 22 | } 23 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Internal/RedisLogTextWriter.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using Microsoft.Extensions.Logging; 3 | 4 | namespace NetFusion.Integration.Redis.Internal 5 | { 6 | /// 7 | /// Implementation that writes Redis connection logs to 8 | /// the configured logger. 9 | /// 10 | public class RedisLogTextWriter(ILogger logger) : TextWriter 11 | { 12 | private readonly ILogger _logger = logger ?? throw new ArgumentNullException(nameof(logger)); 13 | public override Encoding Encoding { get; } = Encoding.UTF8; 14 | 15 | public override void Write(string? value) 16 | { 17 | if (! string.IsNullOrWhiteSpace(value)) 18 | { 19 | _logger.LogTrace("Redis Log: {Message}", value); 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Models/ApiRelationDoc.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Models; 2 | 3 | /// 4 | /// Model containing a linked relation associated with a resource. 5 | /// 6 | public class ApiRelationDoc 7 | { 8 | /// 9 | /// The name of the relation. 10 | /// 11 | public string Name { get; set; } 12 | 13 | /// 14 | /// The method used to invoke the action associated with the relation. 15 | /// 16 | public string Method { get; set; } 17 | 18 | /// 19 | /// The Url used to invoke the action associated with the relation. 20 | /// 21 | public string HRef { get; set; } 22 | 23 | /// 24 | /// Description of the relation. 25 | /// 26 | public string Description { get; set; } 27 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/Subscriber/HostAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetFusion.AMQP.Subscriber 4 | { 5 | /// 6 | /// Attribute specified on a class implementing the IMessageConsumer marker 7 | /// interface used to specify the Amqp host configuration defined in the 8 | /// application's configuration settings. 9 | /// 10 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 11 | public class HostAttribute : Attribute 12 | { 13 | /// 14 | /// The name of the host specified within the application's settings. 15 | /// 16 | public string HostName { get; } 17 | 18 | public HostAttribute(string hostName) 19 | { 20 | HostName = hostName ?? throw new ArgumentNullException(nameof(hostName)); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/IMessageDispatcherService.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging; 2 | 3 | public interface IMessageDispatcherService 4 | { 5 | /// 6 | /// Service used to dispatch messages that are received outside of the 7 | /// scope associated with a given web request such as a message received 8 | /// from a message bus. 9 | /// 10 | /// The dispatcher to be used to deliver message. 11 | /// The message to be dispatched. 12 | /// The cancellation token. 13 | /// Optional message response. 14 | Task InvokeDispatcherInNewLifetimeScopeAsync(MessageDispatcher dispatcher, 15 | IMessage message, 16 | CancellationToken cancellationToken = default); 17 | 18 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Publisher/ChannelPublisherEntity.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.Bus.Entities; 2 | using NetFusion.Integration.Redis.Publisher.Metadata; 3 | using NetFusion.Integration.Redis.Publisher.Strategies; 4 | 5 | namespace NetFusion.Integration.Redis.Publisher; 6 | 7 | public class ChannelPublisherEntity : BusEntity 8 | { 9 | public Type DomainEventType { get; } 10 | public PublishMeta PublishMeta { get; } 11 | 12 | public ChannelPublisherEntity(Type domainEventType, string busName, string channelName, 13 | PublishMeta publishMeta) : 14 | base(busName, channelName) 15 | { 16 | DomainEventType = domainEventType; 17 | PublishMeta = publishMeta ?? throw new ArgumentNullException(nameof(publishMeta)); 18 | 19 | AddStrategies(new ChannelPublishStrategy(this)); 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Xml/Descriptions/XmlActionComments.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NetFusion.Web.Metadata; 3 | using NetFusion.Web.Rest.Docs.Core.Descriptions; 4 | using NetFusion.Web.Rest.Docs.Models; 5 | 6 | namespace NetFusion.Web.Rest.Docs.Xml.Descriptions; 7 | 8 | /// 9 | /// Sets the comments associated with a given Web Controller's action method 10 | /// from a .NET Code Comment XML file. 11 | /// 12 | public class XmlActionComments(IXmlCommentService xmlComments) : IActionDescription 13 | { 14 | private readonly IXmlCommentService _xmlComments = xmlComments ?? 15 | throw new ArgumentNullException(nameof(xmlComments)); 16 | 17 | public void Describe(ApiActionDoc actionDoc, ApiActionMeta actionMeta) 18 | { 19 | actionDoc.Description = _xmlComments.GetMethodComments(actionMeta.ActionMethodInfo); 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.UnitTests/Messaging/TestSetupExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using NetFusion.Core.Bootstrap.Container; 3 | using NetFusion.Core.TestFixtures.Plugins; 4 | using NetFusion.Messaging.Plugin; 5 | 6 | namespace NetFusion.Messaging.UnitTests.Messaging; 7 | 8 | public static class TestSetupExtensions 9 | { 10 | // Adds a host plugin configured with the core messaging plugin. 11 | public static ICompositeContainer AddMessagingHost(this ICompositeContainer container) 12 | { 13 | container.ServiceCollection.AddSingleton(); 14 | 15 | var hostPlugin = new MockHostPlugin(); 16 | 17 | container.RegisterPlugins(hostPlugin); 18 | container.RegisterPlugin(); 19 | 20 | return container; 21 | } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/Settings/AmqpHostSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NetFusion.Base.Validation; 3 | using NetFusion.Settings; 4 | 5 | namespace NetFusion.AMQP.Settings 6 | { 7 | /// 8 | /// AMQP settings used by the application. 9 | /// 10 | [ConfigurationSection("netfusion:amqp")] 11 | public class AmqpHostSettings : IAppSettings, 12 | IValidatableType 13 | { 14 | /// 15 | /// The configured hosts. 16 | /// 17 | public ICollection Hosts { get; set; } 18 | 19 | public AmqpHostSettings() 20 | { 21 | Hosts = new List(); 22 | } 23 | 24 | public void Validate(IObjectValidator validator) 25 | { 26 | validator.AddChildren(Hosts); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Bootstrap/Plugins/PluginTypes.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Core.Bootstrap.Plugins; 2 | 3 | /// 4 | /// Used to identify a type of plugin. 5 | /// 6 | public enum PluginTypes 7 | { 8 | /// 9 | /// This is the process executing the application and defining the GenericHost. 10 | /// There can only be one host plugin added to the CompositeCollection. 11 | /// 12 | HostPlugin = 1, 13 | 14 | /// 15 | /// An application level centric plugin. Application centric plugins are used to organize an 16 | /// application's implementation. 17 | /// 18 | AppPlugin = 2, 19 | 20 | /// 21 | /// Core plugins contain reusable and crosscutting implementations that can optionally 22 | /// be used by applications. 23 | /// 24 | CorePlugin = 3 25 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Settings/Mocks/MockSetttings.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | using NetFusion.Core.Settings; 3 | 4 | namespace NetFusion.Core.UnitTests.Settings.Mocks; 5 | 6 | [ConfigurationSection("App:MainWindow")] 7 | public class MockSettings : IAppSettings 8 | { 9 | public int Height { get; set; } = 1000; 10 | public int Width { get; set; } = 2000; 11 | } 12 | 13 | public class MockDerivedSettings: MockSettings 14 | { 15 | public Dialog Dialog { get; set; } 16 | } 17 | 18 | public class Dialog 19 | { 20 | public Colors Colors { get; set;} 21 | } 22 | 23 | public class Colors { 24 | public string Frame { get; set; } 25 | public string Title { get; set; } 26 | } 27 | 28 | public class MockInvalidSettings : MockSettings 29 | { 30 | [Range(5, 100, ErrorMessage = "Invalid Range")] 31 | public int ValidatedValue { get; set; } 32 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Messaging/Enrichers/DateOccurredEnricher.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Enrichers; 2 | using NetFusion.Messaging.Types.Attributes; 3 | using NetFusion.Messaging.Types.Contracts; 4 | 5 | namespace NetFusion.Services.Messaging.Enrichers; 6 | 7 | /// 8 | /// Adds the current date and time to the message if not already present. 9 | /// 10 | public class DateOccurredEnricher : IMessageEnricher 11 | { 12 | // The MessageEnricherModule registers all enrichers with a scoped lifetime. Therefore, 13 | // the below date value will be the same for all published messages during a given request. 14 | private readonly DateTime _scopedDateReceived = DateTime.UtcNow; 15 | 16 | public Task EnrichAsync(IMessage message) 17 | { 18 | message.SetUtcDateOccurred(_scopedDateReceived); 19 | return Task.CompletedTask; 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common/Extensions/Collections/DictionaryExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace NetFusion.Common.Extensions.Collections; 5 | 6 | public static class DictionaryExtensions 7 | { 8 | public static string ToKeyValuePairString(this IDictionary dictionary) => 9 | string.Join(", ", dictionary.Where(kv => kv.Value != null) 10 | .Select((k, v) => $"{k}={v}") 11 | .ToArray() 12 | ); 13 | 14 | public static string ToKeyValuePairString(this IDictionary dictionary) => 15 | string.Join(", ", dictionary.Select((k, v) => $"{k}={v}").ToArray()); 16 | 17 | public static Dictionary RemoveNullValues(this IDictionary dictionary) => 18 | dictionary.Where(kv => kv.Value != null).ToDictionary(kv => kv.Key, kv => kv.Value)!; 19 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/Subscriber/QueueAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NetFusion.AMQP.Subscriber.Internal; 3 | 4 | namespace NetFusion.AMQP.Subscriber 5 | { 6 | /// 7 | /// Attribute used to specify a queue defined on a namespace that 8 | /// should be invoked when a message arrives. 9 | /// 10 | public class QueueAttribute : HostItemAttribute 11 | { 12 | /// 13 | /// The name of the defined queue. 14 | /// 15 | public string QueueName { get; } 16 | 17 | public QueueAttribute(string queue) 18 | : base (new QueueSubscriberLinker()) 19 | { 20 | if (string.IsNullOrWhiteSpace(queue)) 21 | throw new ArgumentException("Queue name not specified.", nameof(queue)); 22 | 23 | QueueName = queue; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Server/Meta/IResourceMeta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NetFusion.Web.Rest.Server.Linking; 4 | 5 | namespace NetFusion.Web.Rest.Server.Meta; 6 | 7 | /// 8 | /// Common resource metadata associated with a source type. 9 | /// 10 | public interface IResourceMeta 11 | { 12 | /// 13 | /// The source type associated with the metadata. 14 | /// 15 | Type SourceType { get; } 16 | 17 | /// 18 | /// The link metadata associated with the source type. Based on how the link is selected or specified, 19 | /// one of the derived ResourceLink classes will be added to this collection. If the link is just a 20 | /// hard-coded string, then an instance of the the base ResourceLink class is added. 21 | /// 22 | IReadOnlyCollection Links { get; } 23 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Messaging/NetFusion.Services.Messaging.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | NetFusion.Services.Messaging 16 | NetFusion Messaging Services 17 | Additional messaging features 18 | netfusion;plugin;messaging 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Core/Descriptions/IRelationDescription.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Docs.Models; 2 | using NetFusion.Web.Rest.Server.Linking; 3 | 4 | namespace NetFusion.Web.Rest.Docs.Core.Descriptions; 5 | 6 | /// 7 | /// Interface implemented by a class responsible for describing 8 | /// a relation associated with a resource. 9 | /// 10 | public interface IRelationDescription : IDocDescription 11 | { 12 | /// 13 | /// Called to add documentation to a resource's relation. 14 | /// 15 | /// The resource for which the relation is associated. 16 | /// The created relation document model. 17 | /// The link associated with the relation. 18 | void Describe(ApiResourceDoc resourceDoc, ApiRelationDoc relationDoc, ResourceLink resourceLink); 19 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ClientRequests/Server/ErrorController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using NetFusion.Web.UnitTests.Mocks; 5 | 6 | namespace NetFusion.Web.UnitTests.Rest.ClientRequests.Server; 7 | 8 | [ApiController, Route("api/error")] 9 | public class ErrorController(IMockedService mockedService) : ControllerBase 10 | { 11 | private readonly IMockedService _mockedService = mockedService; 12 | 13 | [HttpGet("server/side")] 14 | public void ServerSideError() 15 | { 16 | if (_mockedService.TriggerServerSideException) 17 | { 18 | throw new InvalidOperationException("Test-Exception"); 19 | } 20 | } 21 | 22 | [HttpGet("server/http/error-code")] 23 | public IActionResult HttpErrorCode() 24 | { 25 | return StatusCode(StatusCodes.Status404NotFound); 26 | } 27 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/Publisher/IHostRegistry.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NetFusion.AMQP.Publisher.Internal; 3 | using NetFusion.Base.Plugins; 4 | 5 | namespace NetFusion.AMQP.Publisher 6 | { 7 | /// 8 | /// Discovered when the PublisherModule is initialized. A host registry is responsible 9 | /// for providing the metadata about defined host items (i.e. Queue/Topic). This metadata 10 | /// is cached and used to create the AMQP objects when sending and receiving messages. 11 | /// 12 | public interface IHostRegistry : IKnownPluginType 13 | { 14 | /// 15 | /// Called during the bootstrap process and returns the metadata for the 16 | /// objects defined on the host. 17 | /// 18 | /// List of host item metadata. 19 | IEnumerable GetItems(); 20 | } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.UnitTests/Mapping/Strategies/TestDerivedStrategyFactory.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Services.Mapping; 2 | using NetFusion.Services.UnitTests.Mapping.Entities; 3 | 4 | namespace NetFusion.Services.UnitTests.Mapping.Strategies; 5 | 6 | public class TestDerivedStrategyFactory : IMappingStrategyFactory 7 | { 8 | public IEnumerable GetStrategies() 9 | { 10 | yield return DelegateMap.Map((Customer s) => new CustomerSummary 11 | { 12 | Description = $"{s.FirstName}-{s.LastName}", 13 | FirstName = s.FirstName, 14 | LastName = s.LastName 15 | }); 16 | 17 | yield return DelegateMap.Map((Car s) => 18 | 19 | new CarSummary { 20 | Description = $"{s.Make}-{s.Model}", 21 | Make = s.Make, 22 | Model = s.Model 23 | }); 24 | } 25 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Messaging/Enrichers/HostEnricher.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Container; 2 | using NetFusion.Messaging.Enrichers; 3 | using NetFusion.Messaging.Types.Attributes; 4 | using NetFusion.Messaging.Types.Contracts; 5 | 6 | namespace NetFusion.Services.Messaging.Enrichers; 7 | 8 | /// 9 | /// Enricher that tags all messages with the name and identity 10 | /// of the Microservice from where the message was published. 11 | /// 12 | public class HostEnricher(ICompositeApp compositeApp) : IMessageEnricher 13 | { 14 | private readonly ICompositeApp _compositeApp = compositeApp; 15 | 16 | public Task EnrichAsync(IMessage message) 17 | { 18 | message.Attributes.SetStringValue("Microservice", _compositeApp.HostPlugin.Name); 19 | message.Attributes.SetStringValue("MicroserviceId", _compositeApp.HostPlugin.PluginId); 20 | return Task.CompletedTask; 21 | } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Plugin/Settings/RuleSettings.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace NetFusion.Integration.ServiceBus.Plugin.Settings; 4 | 5 | /// 6 | /// Settings for storing subscription rules externally within 7 | /// the application's configuration. 8 | /// 9 | public class RuleSettings 10 | { 11 | /// 12 | /// The filter used to match messages to be delivered to a subscription. 13 | /// 14 | [Required(AllowEmptyStrings = false, ErrorMessage = "Filter must have value specified.")] 15 | public string Filter { get; set; } = null!; 16 | 17 | /// 18 | /// Optional action that should be applied to the message matching the filter. 19 | /// A string value added to the message's properties on which other filters can 20 | /// be based. 21 | /// 22 | public string? Action { get; set; } 23 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Core/Descriptions/IParameterDescription.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Metadata; 2 | using NetFusion.Web.Rest.Docs.Models; 3 | 4 | namespace NetFusion.Web.Rest.Docs.Core.Descriptions; 5 | 6 | /// 7 | /// Interface implemented by a class responsible for describing 8 | /// a parameter associated with an action method. 9 | /// 10 | public interface IParameterDescription : IDocDescription 11 | { 12 | /// 13 | /// Add documentation to an action method's parameter definition. 14 | /// 15 | /// The created parameter document. 16 | /// The action metadata containing the defined parameter. 17 | /// The metadata from which the document model was created. 18 | void Describe(ApiParameterDoc parameterDoc, ApiActionMeta actionMeta, ApiParameterMeta parameterMeta); 19 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Models/ApiEmbeddedDoc.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Models; 2 | 3 | /// 4 | /// Model describing a named resource embedded within a parent resource. 5 | /// 6 | public class ApiEmbeddedDoc 7 | { 8 | /// 9 | /// The name describing what the embedded resource represents. 10 | /// 11 | public string EmbeddedName { get; set; } 12 | 13 | /// 14 | /// Indicates that a collection of resources are embedded. 15 | /// 16 | public bool IsCollection { get; set; } 17 | 18 | /// 19 | /// Information on how the embedded resource type relates to the parent. 20 | /// 21 | public string Description { get; set; } 22 | 23 | /// 24 | /// Documentation associated with the embedded resource. 25 | /// 26 | public ApiResourceDoc ResourceDoc { get; set; } 27 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.CodeGen/IApiCodeGenService.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using System.IO; 3 | 4 | namespace NetFusion.Web.Rest.CodeGen; 5 | 6 | /// 7 | /// Service providing access to generated TypeScript corresponding 8 | /// to the C# models exposed by the API. 9 | /// 10 | public interface IApiCodeGenService 11 | { 12 | /// 13 | /// Looks up the generated code corresponding to a resource. 14 | /// 15 | /// The name of the resource. 16 | /// If the resource's corresponding code file is 17 | /// found, a reference to the corresponding stream will be returned. 18 | /// 19 | /// True if the code-generated Typescript with the specified 20 | /// resource name is found. Otherwise, False is returned. 21 | bool TryGetResourceCodeFile(string resourceName, [MaybeNullWhen(false)]out Stream stream); 22 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/Setup/MockUnitTestService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.AspNetCore.Http; 5 | using NetFusion.Web.Rest.Resources; 6 | using NetFusion.Web.UnitTests.Mocks; 7 | using NetFusion.Web.UnitTests.Rest.ClientRequests.Server; 8 | 9 | namespace NetFusion.Web.UnitTests.Rest.Setup; 10 | 11 | public class MockUnitTestService : IMockedService 12 | { 13 | public IEnumerable ServerResources { get; set; } 14 | public HalResource ServerReceivedResource { get; set; } 15 | 16 | public IEnumerable GetResources() 17 | { 18 | return ServerResources.OfType(); 19 | } 20 | 21 | public bool TriggerServerSideException { get; set; } = false; 22 | public int ReturnsStatusCode { get; set; } = StatusCodes.Status200OK; 23 | 24 | 25 | public IEnumerable Customers { get; set; } = Array.Empty(); 26 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/NetFusion.Integration.Bus.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | NetFusion.Integration.Bus 11 | NetFusion Messaging Integration 12 | Assembly containing common message integration classes. 13 | netfusion;plugin;messaging 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.CodeGen/Plugin/RestCodeGenExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Builder; 3 | 4 | namespace NetFusion.Web.Rest.CodeGen.Plugin; 5 | 6 | /// 7 | /// Extension methods for IApplicationBuilder that can be used 8 | /// when configuring a WebApi service. 9 | /// 10 | public static class RestCodeGenExtensions 11 | { 12 | /// 13 | /// Adds a middleware component to the ASP.NET Core pipeline called 14 | /// to obtain the corresponding TypeScript generated code. 15 | /// 16 | /// The ASP.NET Core application builder. 17 | /// Application Builder 18 | public static IApplicationBuilder UseRestCodeGen(this IApplicationBuilder builder) 19 | { 20 | ArgumentNullException.ThrowIfNull(builder); 21 | 22 | builder.UseMiddleware(); 23 | return builder; 24 | } 25 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Scripting/IEntityScriptMetaRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | 4 | namespace NetFusion.Common.Base.Scripting; 5 | 6 | /// 7 | /// Responsible for maintaining a set of entity related scripts that can 8 | /// be executed at runtime against the entity. 9 | /// 10 | public interface IEntityScriptMetaRepository 11 | { 12 | /// 13 | /// Returns a list of all the configured entity scripts. 14 | /// 15 | /// List of domain entity associated scripts. 16 | Task> ReadAllAsync(); 17 | 18 | /// 19 | /// Saves a new script or updates an existing. 20 | /// 21 | /// The script to save. 22 | /// The existing identity value or the newly generated value. 23 | Task SaveAsync(EntityScript script); 24 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/QueryReadModel.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using Destructurama.Attributed; 3 | using NetFusion.Common.Base.Entity; 4 | 5 | namespace NetFusion.Messaging.Types; 6 | 7 | /// 8 | /// A model from which a query result can be derived to add a set of dynamic properties. 9 | /// 10 | public abstract class QueryReadModel : IAttributedEntity 11 | { 12 | /// 13 | /// Set of dynamic properties associated with the model. 14 | /// 15 | [JsonIgnore, NotLogged] 16 | public IEntityAttributes Attributes { get; } = new EntityAttributes(); 17 | 18 | /// 19 | /// Used during serialization to set and retrieve the properties associated with the module. 20 | /// 21 | public IDictionary AttributeValues 22 | { 23 | get => Attributes.GetValues(); 24 | set => Attributes.SetValues(value); 25 | } 26 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Plugin/INamespaceModule.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.ServiceBus.Namespaces; 2 | using NetFusion.Integration.ServiceBus.Plugin.Configs; 3 | 4 | namespace NetFusion.Integration.ServiceBus.Plugin; 5 | 6 | /// 7 | /// Module responsible for managing Namespace connections and configurations. 8 | /// 9 | public interface INamespaceModule : IPluginModuleService 10 | { 11 | /// 12 | /// Plugin configuration provided when microservice is bootstrapped. 13 | /// 14 | ServiceBusConfig BusPluginConfiguration { get; } 15 | 16 | /// 17 | /// Returns the connection for a given namespace. 18 | /// 19 | /// The namespace to fine corresponding connection. 20 | /// The connection if found. Otherwise, an exception is raised. 21 | NamespaceConnection GetConnection(string namespaceName); 22 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/NetFusion.Messaging.Types.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | NetFusion.Messaging.Types 17 | NetFusion Domain Messaging 18 | Assembly containing base types used for defining message type within the business domain. 19 | netfusion;messaging;ddd 20 | 21 | 22 | -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Roslyn/Internal/ExpressionEvaluator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.CodeAnalysis.Scripting; 3 | using NetFusion.Common.Base.Scripting; 4 | 5 | namespace NetFusion.Services.Roslyn.Internal; 6 | 7 | /// 8 | /// The entity expression and the associated compiled script to be executed at runtime. 9 | /// 10 | public class ExpressionEvaluator( 11 | EntityExpression expression, 12 | ScriptRunner scriptRunner) 13 | { 14 | /// 15 | /// The expression from which the ScriptRunner was created. 16 | /// 17 | public EntityExpression Expression { get; } = expression ?? throw new ArgumentNullException(nameof(expression)); 18 | 19 | /// 20 | /// The expression compiled to a delegate to be executed at runtime. 21 | /// 22 | public ScriptRunner ScriptRunner { get; } = scriptRunner ?? throw new ArgumentNullException(nameof(scriptRunner)); 23 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Plugin/Settings/DbEndPoint.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Validation; 2 | 3 | namespace NetFusion.Integration.Redis.Plugin.Settings 4 | { 5 | /// 6 | /// Settings for a specific Redis database instance. 7 | /// 8 | public class DbEndPoint : IValidatableType 9 | { 10 | /// 11 | /// The host of the Redis server. 12 | /// 13 | public string Host { get; set; } = string.Empty; 14 | 15 | /// 16 | /// The port on which the server is listening for requests. 17 | /// 18 | public int Port { get; set; } 19 | 20 | public void Validate(IObjectValidator validator) 21 | { 22 | validator.Verify(! string.IsNullOrWhiteSpace(Host), "Endpoint Host not specified."); 23 | validator.Verify(Port > 0, "Endpoint Port must be greater than zero."); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Resources/NetFusion.Web.Rest.Resources.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | NetFusion.Web.Rest.Resources 17 | NetFusion REST Resource Models 18 | Contains Resource Models exposed by a Service's Public API. 19 | netfusion;plugin;rest;hal;http;client; 20 | 21 | -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Resources/ResourceExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NetFusion.Common.Extensions.Reflection; 3 | 4 | namespace NetFusion.Web.Rest.Resources; 5 | 6 | public static class ResourceExtensions 7 | { 8 | /// 9 | /// Returns the resource name associated with a model type. The resource name 10 | /// of the model is exposed from the RestApi and becomes part of the contract. 11 | /// 12 | /// The model type. 13 | /// The resource name specified by ResourceAttribute. 14 | /// If the attribute is not present, the class name of the model is returned. 15 | public static string GetResourceName(this Type modelType) 16 | { 17 | if (modelType == null) throw new ArgumentNullException(nameof(modelType), 18 | "Model Type cannot be null."); 19 | 20 | return modelType.GetAttribute()?.ResourceName ?? modelType.Name; 21 | } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Plugin/Modules/NamespaceEntityModule.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Integration.Bus.Entities; 2 | using NetFusion.Integration.ServiceBus.Namespaces; 3 | using NetFusion.Integration.ServiceBus.Queues; 4 | 5 | namespace NetFusion.Integration.ServiceBus.Plugin.Modules; 6 | 7 | /// 8 | /// Module managing the initialization of namespace entities determining how 9 | /// messages are published and received from Azure Service Bus. 10 | /// 11 | internal class NamespaceEntityModule : BusEntityModuleBase, 12 | INamespaceEntityModule 13 | { 14 | public override void RegisterServices(IServiceCollection services) 15 | { 16 | services.AddScoped(); 17 | base.RegisterServices(services); 18 | } 19 | 20 | protected override BusEntityContext CreateContext(IServiceProvider services) => 21 | new NamespaceEntityContext(Context.AppHost, services); 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Plugin/Settings/BusSettings.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Validation; 2 | using NetFusion.Core.Settings; 3 | 4 | namespace NetFusion.Integration.ServiceBus.Plugin.Settings; 5 | 6 | /// 7 | /// Settings specifying Azure Service Bus namespace configurations. 8 | /// 9 | [ConfigurationSection("azure:serviceBus")] 10 | public class BusSettings : IAppSettings, 11 | IValidatableType 12 | { 13 | /// 14 | /// The configured namespaces. 15 | /// 16 | public IDictionary Namespaces { get; set; } = new Dictionary(); 17 | 18 | public void InitConfiguration() 19 | { 20 | foreach (var (name, ns) in Namespaces) 21 | { 22 | ns.Name = name; 23 | } 24 | } 25 | 26 | public void Validate(IObjectValidator validator) 27 | { 28 | validator.AddChildren(Namespaces.Values); 29 | } 30 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Server/Linking/ResourceLink.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Server.Linking; 2 | 3 | /// 4 | /// Defines a link with an associated relation name. The relation name indicates how 5 | /// the link is associated to the resource. For example, the resource is a customer, 6 | /// there could be an associated resource-links with the relation names of: 7 | /// - self: The URL that can be used to reload the resource. 8 | /// - mailing-address: The URL used to load the customer's mailing address. 9 | /// - pending-orders: The URL used to load the customer's pending orders. 10 | /// 11 | public class ResourceLink(string relationName) 12 | { 13 | public string RelationName { get; } = relationName; 14 | 15 | public string? Href { get; set; } 16 | public string Method { get; set; } = string.Empty; 17 | 18 | public string? Title { get; set; } 19 | public string? Type { get; set; } 20 | public string? HrefLang { get; set; } 21 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Exceptions/FilterException.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Exceptions; 2 | using NetFusion.Messaging.Filters; 3 | 4 | namespace NetFusion.Messaging.Exceptions; 5 | 6 | /// 7 | /// Contains information about a query filter that threw an exception 8 | /// when applied. 9 | /// 10 | public class FilterException : NetFusionException 11 | { 12 | /// 13 | /// 14 | /// 15 | /// Message describing the exception. 16 | /// The associated filter that raised exception. 17 | /// The aggregate exception associated with task. 18 | public FilterException(string message, IMessageFilter filter, AggregateException? aggregateException) 19 | : base(message, aggregateException) 20 | { 21 | ArgumentNullException.ThrowIfNull(filter); 22 | 23 | Details["Filter"] = filter.GetType().FullName!; 24 | } 25 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Serialization/JsonMessageSerializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Text.Json; 4 | using NetFusion.Common.Base; 5 | using NetFusion.Common.Base.Serialization; 6 | 7 | namespace NetFusion.Services.Serialization; 8 | 9 | /// 10 | /// Serializes a value to JSON representation. 11 | /// 12 | public class JsonMessageSerializer : ISerializer 13 | { 14 | public string ContentType => ContentTypes.Json; 15 | public string EncodingType => Encoding.UTF8.WebName; 16 | 17 | public byte[] Serialize(object value) 18 | { 19 | ArgumentNullException.ThrowIfNull(value); 20 | 21 | return JsonSerializer.SerializeToUtf8Bytes(value); 22 | } 23 | 24 | public object? Deserialize(byte[] value, Type valueType) 25 | { 26 | ArgumentNullException.ThrowIfNull(value); 27 | ArgumentNullException.ThrowIfNull(valueType); 28 | 29 | return JsonSerializer.Deserialize(value, valueType); 30 | } 31 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.RabbitMQ/Internal/ConsumerErrorStrategy.cs: -------------------------------------------------------------------------------- 1 | using EasyNetQ.Consumer; 2 | 3 | namespace NetFusion.Integration.RabbitMQ.Internal; 4 | 5 | /// 6 | /// The following will disable the default error strategy provided 7 | /// by EasyNetQ allowing the RabbitMQ x-dead-letter-exchange queue 8 | /// attribute to be used. 9 | /// 10 | public class ConsumerErrorStrategy : IConsumerErrorStrategy 11 | { 12 | public void Dispose() 13 | { 14 | 15 | } 16 | 17 | public Task HandleConsumerErrorAsync(ConsumerExecutionContext context, Exception exception, 18 | CancellationToken cancellationToken = new()) 19 | { 20 | return Task.FromResult(AckStrategies.NackWithoutRequeue); 21 | } 22 | 23 | public Task HandleConsumerCancelledAsync(ConsumerExecutionContext context, 24 | CancellationToken cancellationToken = new()) 25 | { 26 | return Task.FromResult(AckStrategies.NackWithRequeue); 27 | } 28 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Serilog/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using NetFusion.Common.Base.Logging; 4 | 5 | namespace NetFusion.Services.Serilog; 6 | 7 | public static class ServiceCollectionExtensions 8 | { 9 | /// 10 | /// Adds to the service collection a service used to change the minimum log level at runtime. 11 | /// 12 | /// The service collection. 13 | /// The service used to change the log level. 14 | /// The service collection. 15 | public static IServiceCollection AddLogLevelControl(this IServiceCollection services, 16 | ILogLevelControl logLevelControl) 17 | { 18 | ArgumentNullException.ThrowIfNull(services); 19 | ArgumentNullException.ThrowIfNull(logLevelControl); 20 | 21 | services.AddSingleton(logLevelControl); 22 | return services; 23 | } 24 | } -------------------------------------------------------------------------------- /.github/workflows/branches-build.yml: -------------------------------------------------------------------------------- 1 | name: Branches Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - develop 7 | - current-feature 8 | - netfusion-core-current 9 | 10 | paths: 11 | - 'netfusion/**' 12 | env: 13 | solution: ./netfusion/NetFusion.sln 14 | packageDir: ./netfusion/pkgs 15 | 16 | jobs: 17 | build: 18 | env: 19 | buildVersion: '8.0.${{github.run_number}}' 20 | nugetAuthToken: ${{ secrets.NuGetAPIKey }} 21 | 22 | runs-on: ubuntu-latest 23 | 24 | steps: 25 | - uses: actions/checkout@v2 26 | - name: Setup .NET 27 | uses: actions/setup-dotnet@v1 28 | with: 29 | dotnet-version: 8.0.101 30 | - name: Print Variables 31 | run: echo $buildVersion 32 | - name: Restore Dependencies 33 | run: dotnet restore $solution 34 | - name: Build for Test 35 | run: dotnet build --no-restore --version-suffix $buildVersion $solution 36 | - name: Test 37 | run: dotnet test --no-build --verbosity normal $solution 38 | -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web/Extensions/HttpContextExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace NetFusion.Web.Extensions; 6 | 7 | /// 8 | /// HTTP Context extensions for use within MVC based classes such as formatters. 9 | /// 10 | public static class HttpContextExtensions 11 | { 12 | /// 13 | /// Returns a service registered with the dependency injection container from 14 | /// the context of a Web MVC component class. 15 | /// 16 | /// The type of the service to receive. 17 | /// The httpContext of the current request. 18 | /// The registered service. 19 | public static T GetService(this HttpContext httpContext) 20 | { 21 | ArgumentNullException.ThrowIfNull(httpContext); 22 | 23 | return (T)httpContext.RequestServices.GetRequiredService(typeof(T)); 24 | } 25 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Plugin/INamespaceEntityModule.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using NetFusion.Integration.Bus.Entities; 3 | 4 | namespace NetFusion.Integration.ServiceBus.Plugin; 5 | 6 | /// 7 | /// Module managing the initialization of namespace entities determining how 8 | /// messages are published and received from Azure Service Bus. 9 | /// 10 | internal interface INamespaceEntityModule : IPluginModuleService 11 | { 12 | /// 13 | /// Returns the namespace entity responsible for publishing a given message type 14 | /// to Azure Service Bus. 15 | /// 16 | /// The type of message being published. 17 | /// The registered namespace entity knowing how to publish the message type. 18 | /// True if an entity is found. Otherwise, False. 19 | bool TryGetPublishEntityForMessage(Type messageType, [NotNullWhen(true)] out BusEntity? entity); 20 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Properties/UrlFilterPropertyTests.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using NetFusion.Common.Base.Properties; 3 | using NetFusion.Core.TestFixtures.Container; 4 | using NetFusion.Core.TestFixtures.Plugins; 5 | 6 | namespace NetFusion.Core.UnitTests.Properties; 7 | 8 | public class UrlFilterPropertyTests 9 | { 10 | [Fact] 11 | public void UrlFilters_CanBeRegistered() 12 | { 13 | ContainerFixture.Test(fixture => 14 | { 15 | fixture.Arrange.Container(c => 16 | { 17 | c.RegisterPlugin(); 18 | }).Act.OnCompositeApp(ca => 19 | { 20 | ca.Properties.AddLogUrlFilter("/mgt/health-check", HttpStatusCode.OK); 21 | }) 22 | .Assert.CompositeApp(ca => 23 | { 24 | ca.Properties.IsLogUrlFilter("/mgt/health-check", HttpStatusCode.OK) 25 | .Should().BeTrue(); 26 | }); 27 | }); 28 | } 29 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.UnitTests/Extensions/Collections/SetTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using NetFusion.Common.Extensions.Collections; 3 | 4 | namespace NetFusion.Common.UnitTests.Extensions.Collections; 5 | 6 | public class SetTests 7 | { 8 | [Fact] 9 | public void GivenSingleValue_DetermineInSet() 10 | { 11 | const int value = 6; 12 | value.InSet(6, 8, 12).Should().BeTrue(); 13 | value.InSet(6, 6, 12).Should().BeTrue(); 14 | value.InSet(55, 99).Should().BeFalse(); 15 | } 16 | 17 | [Fact] 18 | public void GivenValues_DetermineAnyInSet() 19 | { 20 | var values = new[] { 3, 10, 34, 77 }; 21 | values.ContainsAny(10, 34).Should().BeTrue(); 22 | values.ContainsAny(55).Should().BeFalse(); 23 | } 24 | 25 | [Fact] 26 | public void GivenValues_AndComparer_DetermineAnyInSet() 27 | { 28 | var values = new[] {"Value1", "VALUE2", "value3"}; 29 | values.ContainsAny(StringComparer.OrdinalIgnoreCase, "value2").Should().BeTrue(); 30 | } 31 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common/NetFusion.Common.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | NetFusion.Common 17 | NetFusion Common 18 | Common assembly containing common classes and extensions. 19 | netfusion;plugin 20 | 21 | -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging.Types/MessageNamespaceAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Types; 2 | 3 | /// 4 | /// Attribute used to associate an external namespace with the message. 5 | /// The namespace value can be used by a message receiver to determine 6 | /// how the message should be processed. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 9 | public class MessageNamespaceAttribute : Attribute 10 | { 11 | public string MessageNamespace { get; } 12 | 13 | /// 14 | /// Associates an external namespace with a message. 15 | /// 16 | /// External namespace value communicated to message receivers. 17 | public MessageNamespaceAttribute(string messageNamespace) 18 | { 19 | if (string.IsNullOrWhiteSpace(messageNamespace)) 20 | throw new ArgumentException("Message Namespace not specified.", nameof(messageNamespace)); 21 | 22 | MessageNamespace = messageNamespace; 23 | } 24 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common/Extensions/Reflection/ClassificationExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace NetFusion.Common.Extensions.Reflection; 7 | 8 | public static class ClassificationExtensions 9 | { 10 | // Types that are class based but consider to be primitive within this context. 11 | private static IEnumerable PrimitiveTypes { get; } = 12 | [ 13 | typeof(string), 14 | typeof(DateTime), 15 | typeof(decimal) 16 | ]; 17 | 18 | public static bool IsBasicType(this PropertyInfo propertyInfo) 19 | { 20 | ArgumentNullException.ThrowIfNull(propertyInfo); 21 | return propertyInfo.PropertyType.IsBasicType(); 22 | } 23 | 24 | public static bool IsBasicType(this Type type) 25 | { 26 | ArgumentNullException.ThrowIfNull(type); 27 | 28 | type = Nullable.GetUnderlyingType(type) ?? type; 29 | return type.IsPrimitive || PrimitiveTypes.Contains(type); 30 | } 31 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/CodeGeneration/Setup/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Container; 2 | using NetFusion.Core.TestFixtures.Plugins; 3 | using NetFusion.Web.Rest.CodeGen.Plugin; 4 | using NetFusion.Web.UnitTests.Rest.CodeGeneration.Server; 5 | 6 | namespace NetFusion.Web.UnitTests.Rest.CodeGeneration.Setup; 7 | 8 | /// 9 | /// Common test configurations. 10 | /// 11 | public static class TestSetup 12 | { 13 | /// 14 | /// Adds to the composite container the Code-Generation Plugin and a 15 | /// Host Plugin containing two models for which code will be generated. 16 | /// 17 | /// 18 | public static void WithDefaults(ICompositeContainer container) 19 | { 20 | var hostPlugin = new MockHostPlugin(); 21 | hostPlugin.AddPluginType(); 22 | hostPlugin.AddPluginType(); 23 | 24 | container.RegisterPlugins(hostPlugin); 25 | container.RegisterPlugin(); 26 | } 27 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/Subscriber/Internal/HostItemAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetFusion.AMQP.Subscriber.Internal 4 | { 5 | /// 6 | /// Base class from which derived attributes used to specify message 7 | /// handler methods associated with a host item. 8 | /// 9 | [AttributeUsage(AttributeTargets.Method, Inherited = false)] 10 | public abstract class HostItemAttribute : Attribute 11 | { 12 | /// 13 | /// The credit value used when linking to a host item. 14 | /// 15 | public int LinkCredit { get; set; } = 10; 16 | 17 | /// 18 | /// Reference to an object that knows how to link the handler 19 | /// method to the host item. 20 | /// 21 | public ISubscriberLinker Linker { get; } 22 | 23 | protected HostItemAttribute(ISubscriberLinker linker) 24 | { 25 | Linker = linker ?? throw new ArgumentNullException(nameof(linker)); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Internal/IMessagePublisher.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Internal; 2 | 3 | /// 4 | /// Called when a message is published to allow plugins to customize the publishing of messages. 5 | /// For example the InProcessMessagePublisher dispatches messages locally while another publisher 6 | /// could deliver the messages externally to a central message broker. 7 | /// 8 | public interface IMessagePublisher 9 | { 10 | /// 11 | /// Specifies the scope to which publisher sends messages to subscribers. 12 | /// 13 | IntegrationTypes IntegrationType { get; } 14 | 15 | /// 16 | /// Publishes a message asynchronously. 17 | /// 18 | /// The message to be delivered. 19 | /// Cancellation token. 20 | /// The task that will be completed when publishing has completed. 21 | Task PublishMessageAsync(IMessage message, CancellationToken cancellationToken); 22 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.Base/Scripting/NullEntityScriptingService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | 4 | namespace NetFusion.Common.Base.Scripting; 5 | 6 | /// 7 | /// By default, this NULL implementation is registered by the composite-container. 8 | /// However, if the host application wants to utilize dynamic evaluated expresses, they 9 | /// must register an implementation. Such as provided by the NetFusion.Services.Roslyn plugin. 10 | /// 11 | public class NullEntityScriptingService : IEntityScriptingService 12 | { 13 | public void CompileAllScripts() 14 | { 15 | 16 | } 17 | 18 | public Task ExecuteAsync(object entity, string scriptName = "default") 19 | { 20 | return Task.CompletedTask; 21 | } 22 | 23 | public void Load(IEnumerable scripts) 24 | { 25 | 26 | } 27 | 28 | public Task SatisfiesPredicateAsync(object entity, ScriptPredicate predicate) 29 | { 30 | return Task.FromResult(true); 31 | } 32 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.TestFixtures/NetFusion.Core.TestFixtures.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | NetFusion.Core.TestFixtures 18 | NetFusion Test 19 | Assembly containing classes and extensions to aid in unit-testing NetFusion based projects. 20 | netfusion;testing 21 | 22 | -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/DocGeneration/Setup/XmlCommentsSetup.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Web.Rest.Docs.Entities; 2 | using NetFusion.Web.Rest.Docs.Plugin; 3 | using NetFusion.Web.Rest.Docs.Plugin.Configs; 4 | using NetFusion.Web.Rest.Docs.Xml.Services; 5 | 6 | namespace NetFusion.Web.UnitTests.Rest.DocGeneration.Setup; 7 | 8 | public class XmlCommentsSetup 9 | { 10 | public static XmlTypeCommentService TypeService 11 | { 12 | get 13 | { 14 | var docModule = new MockDocModule(); 15 | var xmlCommentSrv = new XmlCommentService(docModule); 16 | return new XmlTypeCommentService(xmlCommentSrv); 17 | } 18 | } 19 | 20 | public static XmlCommentService XmlService 21 | { 22 | get 23 | { 24 | var docModule = new MockDocModule(); 25 | return new XmlCommentService(docModule); 26 | } 27 | } 28 | } 29 | 30 | public class MockDocModule : IDocModule 31 | { 32 | public RestDocConfig RestDocConfig => new(); 33 | public HalComments HalComments => new(); 34 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web/Plugin/WebMvcPlugin.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Container; 2 | using NetFusion.Core.Bootstrap.Plugins; 3 | using NetFusion.Web.Plugin.Modules; 4 | 5 | namespace NetFusion.Web.Plugin; 6 | 7 | public class WebMvcPlugin : PluginBase 8 | { 9 | public override string PluginId => "3C757DE1-48E1-452D-959A-01C8961B43D8"; 10 | public override PluginTypes PluginType => PluginTypes.CorePlugin; 11 | public override string Name => "NetFusion: Web-MVC"; 12 | 13 | public WebMvcPlugin() 14 | { 15 | AddModule(); 16 | 17 | SourceUrl = "https://github.com/grecosoft/NetFusion/tree/master/netfusion/src/Web/NetFusion.Web"; 18 | DocUrl = "https://github.com/grecosoft/NetFusion/wiki"; 19 | } 20 | } 21 | 22 | public static class CompositeBuilderExtensions 23 | { 24 | public static ICompositeContainerBuilder AddWebMvc(this ICompositeContainerBuilder composite) 25 | { 26 | // Add the MVC Plugin: 27 | composite.AddPlugin(); 28 | return composite; 29 | } 30 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Logging/IMessageLogger.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Logging; 2 | 3 | /// 4 | /// Called by message processing code to log message publishing and subscription information. 5 | /// Implementation responsible dispatching a log message to all registered IMessageLogSink 6 | /// implementations. This logging is optional and in addition to the detailed messaging 7 | /// logs written to ILogger. This allows higher-level logs to be correlated. 8 | /// 9 | public interface IMessageLogger 10 | { 11 | /// 12 | /// Logging is enabled if there is one or more registered IMessageLogSink services. 13 | /// 14 | bool IsLoggingEnabled { get; } 15 | 16 | /// 17 | /// Called to record a log. The log is sent to all registered IMessageLogSink services. 18 | /// 19 | /// Contains details of how the message was published or handled. 20 | /// Task indicating a future result. 21 | Task LogAsync(MessageLog messageLog); 22 | } -------------------------------------------------------------------------------- /netfusion/NetFusion.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True 4 | True 5 | True 6 | True 7 | True 8 | True 9 | True -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/MessageExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | using NetFusion.Messaging.Types.Attributes; 3 | using NetFusion.Messaging.Types.Contracts; 4 | 5 | namespace NetFusion.Integration.Bus; 6 | 7 | public static class MessageExtensions 8 | { 9 | public static bool TryParseReplyTo(this IMessage message, 10 | [MaybeNullWhen(false)]out string busName, [MaybeNullWhen(false)]out string queueName) 11 | { 12 | ArgumentNullException.ThrowIfNull(message); 13 | return TryParseReplyTo(message.GetReplyTo(), out busName, out queueName); 14 | } 15 | 16 | public static bool TryParseReplyTo(string? replyTo, 17 | [MaybeNullWhen(false)]out string busName, [MaybeNullWhen(false)]out string queueName) 18 | { 19 | var parts = replyTo?.Split(":"); 20 | if (parts is not { Length: 2 }) 21 | { 22 | busName = queueName = null; 23 | return false; 24 | } 25 | 26 | busName = parts[0]; 27 | queueName = parts[1]; 28 | return true; 29 | } 30 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Settings/SettingsValidationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NetFusion.Common.Base.Validation; 3 | using NetFusion.Common.Extensions; 4 | 5 | namespace NetFusion.Core.Settings; 6 | 7 | /// 8 | /// Exception thrown when configured settings fail validation. 9 | /// 10 | public class SettingsValidationException( 11 | Type settingsType, 12 | string settingSection, 13 | ValidationResultSet validationResults) 14 | : Exception($"Type:{settingsType}; Section: {settingSection}; Results: {validationResults.ToIndentedJson()}") 15 | { 16 | /// 17 | /// The type of the invalid settings class. 18 | /// 19 | public Type SettingsType { get; } = settingsType; 20 | 21 | /// 22 | /// The section path from which the settings were loaded. 23 | /// 24 | public string SettingsSection { get; } = settingSection; 25 | 26 | /// 27 | /// The details of the validation. 28 | /// 29 | public ValidationResultSet ValidationResults { get; } = validationResults; 30 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/IntegrationTests/RabbitMQ/MockBusModule.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using EasyNetQ; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Moq; 5 | using NetFusion.Base.Serialization; 6 | using NetFusion.RabbitMQ.Plugin.Modules; 7 | using NetFusion.Serialization; 8 | 9 | namespace IntegrationTests.RabbitMQ 10 | { 11 | public class MockBusModule : BusModule 12 | { 13 | public List ConnConfigs { get; } 14 | private readonly Mock _mockBus = new(); 15 | 16 | public MockBusModule() 17 | { 18 | ConnConfigs = new List(); 19 | BusFactory = CreateBus; 20 | } 21 | 22 | public override void RegisterServices(IServiceCollection services) 23 | { 24 | services.AddSingleton(); 25 | } 26 | 27 | public IBus CreateBus(ConnectionConfiguration config) 28 | { 29 | ConnConfigs.Add(config); 30 | return _mockBus.Object; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Exceptions/EnricherException.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Exceptions; 2 | using NetFusion.Messaging.Enrichers; 3 | 4 | namespace NetFusion.Messaging.Exceptions; 5 | 6 | /// 7 | /// Contains information about a message enricher that throws and exception when applied. 8 | /// 9 | public class EnricherException : NetFusionException 10 | { 11 | /// 12 | /// Constructor. 13 | /// 14 | /// Message describing the exception. 15 | /// The associated enricher that raised exception. 16 | /// The aggregate exception associated with task. 17 | public EnricherException(string message, IMessageEnricher messageEnricher, 18 | AggregateException? aggregateException) 19 | : base(message, aggregateException) 20 | { 21 | if (messageEnricher == null) throw new NullReferenceException(nameof(messageEnricher)); 22 | 23 | Details["Enricher"] = messageEnricher.GetType().FullName!; 24 | } 25 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Entities/EmbeddedComment.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Entities; 2 | 3 | /// 4 | /// Comments associated with an embedded resource. 5 | /// 6 | public class EmbeddedComment 7 | { 8 | /// 9 | /// The embedded name matching the name specified by the EmbeddedResource Attribute. 10 | /// 11 | public string EmbeddedName { get; set; } 12 | 13 | /// 14 | /// The optional parent resource name, if present, matching the name specified 15 | /// by the EmbeddedResource Attribute. 16 | /// 17 | public string ParentResourceName { get; set; } 18 | 19 | /// 20 | /// The optional child resource name, if present, matching the name specified 21 | /// by the EmbeddedResource Attribute. 22 | /// 23 | public string ChildResourceName { get; set; } 24 | 25 | /// 26 | /// Comment describing how the embedded child resource relates to the parent resource. 27 | /// 28 | public string Comments { get; set; } 29 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Server/Hal/IHalEmbeddedResourceContext.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Server.Hal; 2 | 3 | /// 4 | /// Can be injected by service components responsible for assembling HAL embedded resources. 5 | /// Contains methods used to determine the embedded resources requested from the client. 6 | /// 7 | public interface IHalEmbeddedResourceContext 8 | { 9 | /// 10 | /// Determines if the client has specified the embedded named resource to be returned. 11 | /// 12 | /// The name associated with a embedded resource. 13 | /// True if requested by client. If the client didn't specify, True is returned. 14 | /// False if the client did specify the list of embedded resource names but the provided 15 | /// name is not specified within the list. 16 | bool IsRequested(string embeddedName); 17 | 18 | /// 19 | /// List of the embedded resource model names specified by the requesting client. 20 | /// 21 | string[] RequestedEmbeddedModels { get; } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Common/NetFusion.Common.UnitTests/Extensions/ObjectTests.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using NetFusion.Common.Extensions; 3 | 4 | namespace NetFusion.Common.UnitTests.Extensions; 5 | 6 | public class ObjectTests 7 | { 8 | [Fact] 9 | public void CanSerializeObject_To_IndentedJson() 10 | { 11 | var customer = new Customer 12 | { 13 | Id = Guid.NewGuid().ToString(), 14 | FirstName = "Alex", 15 | LastName = "Green" 16 | }; 17 | 18 | customer.ToIndentedJson().Should().NotBeNullOrEmpty(); 19 | } 20 | 21 | [Fact] 22 | public void CanSerializeObject_to_Json() 23 | { 24 | var customer = new Customer 25 | { 26 | Id = Guid.NewGuid().ToString(), 27 | FirstName = "Alex", 28 | LastName = "Green" 29 | }; 30 | 31 | customer.ToJson().Should().NotBeNullOrEmpty(); 32 | } 33 | 34 | private class Customer 35 | { 36 | public string Id { get; init; } 37 | public string FirstName { get; init; } 38 | public string LastName { get; init; } 39 | } 40 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Messaging/Enrichers/CorrelationEnricher.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Enrichers; 2 | using NetFusion.Messaging.Types.Attributes; 3 | using NetFusion.Messaging.Types.Contracts; 4 | 5 | namespace NetFusion.Services.Messaging.Enrichers; 6 | 7 | /// 8 | /// Adds a GUID value as the message's correlation identifier if not present. 9 | /// 10 | public class CorrelationEnricher : IMessageEnricher 11 | { 12 | // The MessageEnricherModule registers all enrichers with a scoped lifetime. 13 | // Therefore, the below guid value is unique per request for all published messages. 14 | private readonly Guid _scopedRequestId = Guid.NewGuid(); 15 | 16 | public Task EnrichAsync(IMessage message) 17 | { 18 | message.SetCorrelationId(_scopedRequestId.ToString()); 19 | 20 | // This adds an unique value to identity each message. 21 | message.Attributes.SetGuidValue( 22 | AttributeExtensions.GetMessagingScopedName("MessageId"), 23 | Guid.NewGuid(), false); 24 | 25 | return Task.CompletedTask; 26 | } 27 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Server/Linking/ControllerExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using Microsoft.AspNetCore.Mvc.Routing; 6 | using NetFusion.Common.Extensions.Reflection; 7 | 8 | namespace NetFusion.Web.Rest.Server.Linking; 9 | 10 | /// 11 | /// Extension methods for querying a controller's action methods. 12 | /// 13 | public static class ControllerExtensions 14 | { 15 | /// 16 | /// Returns all actions methods for a controller. 17 | /// 18 | /// The type of the controller. 19 | /// Information for all action methods. 20 | public static IEnumerable GetActionMethods(this Type controller) 21 | { 22 | if (controller == null) throw new ArgumentNullException(nameof(controller), 23 | "Controller type cannot be null."); 24 | 25 | return controller.GetMethods( 26 | BindingFlags.DeclaredOnly | 27 | BindingFlags.Instance | 28 | BindingFlags.Public) 29 | .Where(m => m.HasAttribute()); 30 | } 31 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web/NetFusion.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | NetFusion.Web 21 | NetFusion MVC Plug-In 22 | Plug-In containing extensions for ASP.NET core. 23 | netfusion;plugin;asp.net;core 24 | 25 | -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Plugin/Settings/TopicSettings.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Integration.ServiceBus.Plugin.Settings; 2 | 3 | public class TopicSettings 4 | { 5 | /// 6 | /// The maximum size of the topic in megabytes, which is the size of memory allocated for the topic. 7 | /// 8 | public long? MaxSizeInMegabytes { get; set; } 9 | 10 | /// 11 | /// Gets or sets the maximum message size, in kilobytes, for messages sent to this topic. 12 | /// This feature is only available when using a Premium namespace and service version "2021-05" or higher. 13 | /// 14 | /// 15 | public long? MaxMessageSizeInKilobytes { get; set; } 16 | 17 | /// 18 | /// The default time to live value for the messages. This is the duration after which the message expires, 19 | /// starting from when the message is sent to Service Bus. 20 | /// 21 | public int? DefaultMessageTimeToLiveInSeconds { get; set; } 22 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.ServiceBus/Queues/Metadata/QueueRouteMeta.cs: -------------------------------------------------------------------------------- 1 | using Azure.Messaging.ServiceBus; 2 | 3 | namespace NetFusion.Integration.ServiceBus.Queues.Metadata; 4 | 5 | public class QueueRouteMeta 6 | { 7 | public string? QueueName { get; set; } 8 | public TimeSpan? LockDuration { get; set; } 9 | public bool? RequiresSession { get; set; } 10 | public bool? DeadLetteringOnMessageExpiration { get; set; } 11 | public int? MaxDeliveryCount { get; set; } 12 | public string? ForwardDeadLetteredMessagesTo { get; set; } 13 | public long? MaxSizeInMegabytes { get; set; } 14 | public bool? RequiresDuplicateDetection { get; set; } 15 | public TimeSpan? DefaultMessageTimeToLive { get; set; } 16 | public TimeSpan? DuplicateDetectionHistoryTimeWindow { get; set; } 17 | public bool? EnableBatchedOperations { get; set; } 18 | public bool? EnablePartitioning { get; set; } 19 | public ServiceBusProcessorOptions ProcessingOptions { get; } = new(); 20 | } 21 | 22 | public class QueueRouteMeta : QueueRouteMeta, 23 | IRouteMeta 24 | where TCommand : ICommand; -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Mapping/IMappingStrategyFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NetFusion.Core.Bootstrap.Plugins; 3 | 4 | namespace NetFusion.Services.Mapping; 5 | 6 | /// 7 | /// Interface implemented to provide a list of mapping strategy instances. The returned strategy instances are 8 | /// cached and used for all corresponding mappings. These factories are found and called during the application 9 | /// bootstrap. 10 | /// 11 | /// Note: often the consuming application will provide one or more such factories returning instances of the 12 | /// DelegateMap strategy type. The DelegateMap strategy type is a simple strategy providing a function 13 | /// delegate specifying how to map one type to another. The provided function can be from an open-source 14 | /// mapping library of choice. 15 | /// 16 | public interface IMappingStrategyFactory : IPluginKnownType 17 | { 18 | /// 19 | /// List of mapping strategy instances. 20 | /// 21 | /// List of strategies. 22 | IEnumerable GetStrategies(); 23 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Mapping/NetFusion.Services.Mapping.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | NetFusion.Services.Mapping 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | NetFusion.Services.Mapping 18 | NetFusion Mapping Plug-In 19 | Plug-In providing process and structure for mapping objects. Provides extension point for specifying an open-source mapping library of choice. 20 | netfusion;plugin;mapping 21 | 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Brian Greco 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /netfusion/src/Integration/IntegrationTests/RabbitMQ/MockSubscriberModule.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using EasyNetQ; 4 | using EasyNetQ.Topology; 5 | using Moq; 6 | using NetFusion.RabbitMQ.Plugin.Modules; 7 | using NetFusion.RabbitMQ.Subscriber.Internal; 8 | 9 | namespace IntegrationTests.RabbitMQ 10 | { 11 | using NetFusion.RabbitMQ.Metadata; 12 | 13 | public class MockSubscriberModule : SubscriberModule 14 | { 15 | public List CreatedQueues { get; } = new List(); 16 | public List Subscribers { get; } = new List(); 17 | 18 | protected override Task QueueDeclareAsync(IBus bus, QueueMeta queueMeta) 19 | { 20 | CreatedQueues.Add(queueMeta); 21 | 22 | var mockQueue = new Mock(); 23 | return Task.FromResult(mockQueue.Object); 24 | } 25 | 26 | protected override void ConsumeMessageQueue(IBus bus, IQueue queue, MessageQueueSubscriber subscriber) 27 | { 28 | Subscribers.Add(subscriber); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.Settings/ConfigurationSectionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NetFusion.Core.Settings; 4 | 5 | /// 6 | /// Attribute specified on an application setting to indicate the 7 | /// section name from which the setting instance should be populated. 8 | /// 9 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 10 | public class ConfigurationSectionAttribute : Attribute 11 | { 12 | /// 13 | /// The section name. Can be a string or a string separated by the colon 14 | /// character for a nested name. 15 | /// 16 | public string SectionName { get; } 17 | 18 | /// 19 | /// Specifies the sections name use to load the application setting. 20 | /// 21 | /// The section name. Can be a string or a string separated by 22 | /// the colon character for a nested name. 23 | public ConfigurationSectionAttribute(string sectionName) 24 | { 25 | SectionName = sectionName ?? throw new ArgumentNullException(nameof(sectionName), 26 | "Settings configuration name cannot be null."); 27 | } 28 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.UnitTests/Bus/Mocks/TestSerializationManager.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Serialization; 2 | 3 | namespace NetFusion.Integration.UnitTests.Bus.Mocks; 4 | 5 | public class TestSerializationManager : ISerializationManager 6 | { 7 | public IEnumerable Serializers { get; } = Array.Empty(); 8 | 9 | public ISerializer GetSerializer(string contentType, string? encodingType = null) 10 | { 11 | throw new NotImplementedException(); 12 | } 13 | 14 | public byte[] Serialize(object value, string contentType, string? encodingType = null) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | 19 | // ReSharper disable once ReturnTypeCanBeNotNullable 20 | public object? Deserialize(string contentType, Type valueType, byte[] value, string? encodingType = null) 21 | { 22 | throw new NotImplementedException(); 23 | } 24 | 25 | // ReSharper disable once ReturnTypeCanBeNotNullable 26 | public T? Deserialize(string contentType, byte[] value, string? encodingType = null) 27 | { 28 | throw new NotImplementedException(); 29 | } 30 | } -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Serialization/NetFusion.Services.Serialization.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | NetFusion.Services.Serialization 19 | NetFusion Serialization Providers 20 | Assembly providing serialization implementations. 21 | netfusion;plugin;serialization 22 | 23 | -------------------------------------------------------------------------------- /netfusion/src/Services/NetFusion.Services.Serilog/EnricherExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NetFusion.Services.Serilog.Enrichers; 3 | using Serilog; 4 | using Serilog.Configuration; 5 | 6 | namespace NetFusion.Services.Serilog; 7 | 8 | public static class EnricherExtensions 9 | { 10 | /// 11 | /// Enrich log events with a the Plugin Name and Id. These two values are set as the 12 | /// Microservice and MicroserviceId log properties. 13 | /// 14 | /// The Serilog log enricher collection. 15 | /// The unique value used to identify the microservice. 16 | /// The name of the microservice. 17 | /// Configuration object allowing method chaining. 18 | public static LoggerConfiguration WithHostIdentity(this LoggerEnrichmentConfiguration configuration, 19 | string microserviceId, 20 | string microserviceName) 21 | { 22 | ArgumentNullException.ThrowIfNull(configuration); 23 | return configuration.With(new HostIdentityEnricher(microserviceName, microserviceId)); 24 | } 25 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.UnitTests/RabbitMQ/Mocks/TestMessageTypes.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Types; 2 | 3 | namespace NetFusion.Integration.UnitTests.RabbitMQ.Mocks; 4 | 5 | public class TestDomainEvent(int valueOne, int valueTwo) : DomainEvent 6 | { 7 | public int ValueOne { get; } = valueOne; 8 | public int ValueTwo { get; } = valueTwo; 9 | } 10 | 11 | public class TestDomainEventHandler 12 | { 13 | public void OnDomainEvent(TestDomainEvent domainEvent) 14 | { 15 | 16 | } 17 | } 18 | 19 | public class TestCommand : Command; 20 | 21 | public class TestCommandHandler 22 | { 23 | public void OnCommand(TestCommand command) 24 | { 25 | 26 | } 27 | } 28 | 29 | public class TestCommandResponse : Command; 30 | 31 | public class TestCommandWithResponse : Command; 32 | 33 | public class TestCommandHandlerWithResponse 34 | { 35 | public TestCommandResponse OnCommand(TestCommandWithResponse command) 36 | { 37 | return new TestCommandResponse(); 38 | } 39 | } 40 | 41 | public class TestReplyQueueHandler 42 | { 43 | public void OnReply(TestCommandResponse response) 44 | { 45 | 46 | } 47 | } -------------------------------------------------------------------------------- /netfusion/src/Messaging/NetFusion.Messaging/Logging/MessageLogger.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Messaging.Logging; 2 | 3 | /// 4 | /// Called when messages are published or received. Applies any needed common 5 | /// functionality and then sends message to all registered IMessageLogSink 6 | /// instances. 7 | /// 8 | public class MessageLogger : IMessageLogger 9 | { 10 | private readonly IMessageLogSink[] _messageLogSinks; 11 | 12 | public MessageLogger(IEnumerable messageLogSinks) 13 | { 14 | ArgumentNullException.ThrowIfNull(messageLogSinks); 15 | 16 | _messageLogSinks = messageLogSinks.ToArray(); 17 | } 18 | 19 | public bool IsLoggingEnabled => _messageLogSinks.Any(); 20 | 21 | public async Task LogAsync(MessageLog messageLog) 22 | { 23 | ArgumentNullException.ThrowIfNull(messageLog); 24 | 25 | if (! IsLoggingEnabled) 26 | { 27 | return; 28 | } 29 | 30 | messageLog.DateLogged = DateTime.UtcNow; 31 | 32 | foreach (var sink in _messageLogSinks) 33 | { 34 | await sink.WriteLogAsync(messageLog); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/NetFusion.AMQP.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | latest 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | NetFusion.AMQP 19 | NetFusion AMQP Messaging 20 | 21 | Assembly containing base types used for publishing and subscribing to AMQP Hosts. 22 | 23 | netfusion;messaging;amqp 24 | 25 | -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Models/ApiPropertyDoc.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Models; 2 | 3 | /// 4 | /// Model containing a description of a resource's property. 5 | /// 6 | public class ApiPropertyDoc 7 | { 8 | /// 9 | /// The name of the property. 10 | /// 11 | public string Name { get; set; } 12 | 13 | /// 14 | /// Description of the property. 15 | /// 16 | public string Description { get; set; } 17 | 18 | /// 19 | /// Indicates that the type of property is an array. 20 | /// 21 | public bool IsArray { get; set; } 22 | 23 | /// 24 | /// Indicates that a value for the property is required. 25 | /// 26 | public bool IsRequired { get; set; } 27 | 28 | /// 29 | /// The Json type of the property. 30 | /// 31 | public string Type { get; set; } 32 | 33 | /// 34 | /// If the type of property is a class, this property will contain 35 | /// the documentation for the associated resource type. 36 | /// 37 | public ApiResourceDoc ResourceDoc { get; set; } 38 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.UnitTests/Rest/ApiMetadata/Setup/AssertExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using FluentAssertions; 5 | using NetFusion.Web.Metadata; 6 | 7 | namespace NetFusion.Web.UnitTests.Rest.ApiMetadata.Setup; 8 | 9 | public static class AssertExtensions 10 | { 11 | public static void AssertParamMeta(this IEnumerable paramsMeta, string name, 12 | bool isOptional = false, 13 | object defaultValue = null) 14 | { 15 | var paramMeta = paramsMeta.Single(p => p.ParameterName == name); 16 | paramMeta.Should().NotBeNull(); 17 | paramMeta.IsOptional.Should().Be(isOptional); 18 | paramMeta.ParameterType.Should().Be(typeof(T)); 19 | 20 | if (defaultValue != null) 21 | { 22 | paramMeta.DefaultValue.Should().Be(defaultValue); 23 | } 24 | } 25 | 26 | public static void AssertResponseMeta(this IEnumerable responseMeta, int statusCode, 27 | Type responseType = null) 28 | { 29 | responseMeta.Where(m => m.Status == statusCode && m.ModelType == responseType) 30 | .Should().HaveCount(1); 31 | } 32 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.AMQP/Publisher/Internal/IPublisherModule.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NetFusion.Bootstrap.Plugins; 3 | 4 | namespace NetFusion.AMQP.Publisher.Internal 5 | { 6 | /// 7 | /// Contract for module responsible for determining the host items 8 | /// (i.e. Queues/Topics) to which messages can be sent. 9 | /// 10 | public interface IPublisherModule : IPluginModuleService 11 | { 12 | /// 13 | /// Determines if a message type is associated with a host 14 | /// define item. 15 | /// 16 | /// The type of the message. 17 | /// True if a host item is associated with the message type. 18 | bool HasHostItem(Type messageType); 19 | 20 | /// 21 | /// Return the host item associated with a specific message type. 22 | /// 23 | /// The type of the message. 24 | /// The host item. If not items is associated with the 25 | /// message type, an exception is thrown. 26 | IHostItem GetHostItem(Type messageType); 27 | } 28 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Settings/Setup/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using NetFusion.Core.Bootstrap.Container; 3 | using NetFusion.Core.Settings.Plugin; 4 | using NetFusion.Core.TestFixtures.Plugins; 5 | 6 | namespace NetFusion.Core.UnitTests.Settings.Setup; 7 | 8 | public static class TestSetup 9 | { 10 | public static void AddInMemorySettings(IConfigurationBuilder builder) 11 | { 12 | var dict = new Dictionary 13 | { 14 | {"App:MainWindow:Height", "20"}, 15 | {"App:MainWindow:Width", "50"}, 16 | {"App:MainWindows:ValidatedValue", "3" }, 17 | {"App:MainWindow:Dialog:Colors:Frame", "RED"}, 18 | {"App:MainWindow:Dialog:Colors:Title", "DARK_RED"} 19 | }; 20 | 21 | builder.AddInMemoryCollection(dict); 22 | } 23 | 24 | public static void AddSettingsPlugin(ICompositeContainer container, params Type[] settingTypes) 25 | { 26 | var hostPlugin = new MockHostPlugin(); 27 | hostPlugin.AddPluginType(settingTypes); 28 | 29 | container.RegisterPlugins(hostPlugin); 30 | container.RegisterPlugin(); 31 | } 32 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Models/ApiParameterDoc.cs: -------------------------------------------------------------------------------- 1 | namespace NetFusion.Web.Rest.Docs.Models; 2 | 3 | /// 4 | /// Documentation model for the different parameter inputs accepted by a Web Api method. 5 | /// 6 | public class ApiParameterDoc 7 | { 8 | /// 9 | /// The name of the parameter. 10 | /// 11 | public string Name { get; set; } 12 | 13 | /// 14 | /// The Json type of the parameter. 15 | /// 16 | public string Type { get; set; } 17 | 18 | /// 19 | /// The default value of the parameter if not specified. 20 | /// 21 | public string DefaultValue { get; set; } 22 | 23 | /// 24 | /// Indicates if the parameter is optional or must be specified. 25 | /// 26 | public bool IsOptional { get; set; } 27 | 28 | /// 29 | /// Description of the parameter. 30 | /// 31 | public string Description { get; set; } 32 | 33 | /// 34 | /// Contains the documentation for an action method parameter if populated from the message body. 35 | /// 36 | public ApiResourceDoc ResourceDoc { get; set; } 37 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Docs/Xml/Descriptions/XmlParameterComments.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.XPath; 3 | using NetFusion.Web.Metadata; 4 | using NetFusion.Web.Rest.Docs.Core.Descriptions; 5 | using NetFusion.Web.Rest.Docs.Models; 6 | 7 | namespace NetFusion.Web.Rest.Docs.Xml.Descriptions; 8 | 9 | /// 10 | /// Adds additional documentation to an action's parameter from a .NET Code Comment XML file. 11 | /// An action's parameter can be for for a Route, Header, Query, or Body parameter. 12 | /// 13 | public class XmlParameterComments(IXmlCommentService xmlComments) : IParameterDescription 14 | { 15 | private readonly IXmlCommentService _xmlComments = xmlComments ?? 16 | throw new ArgumentNullException(nameof(xmlComments)); 17 | 18 | public void Describe(ApiParameterDoc parameterDoc, ApiActionMeta actionMeta, ApiParameterMeta parameterMeta) 19 | { 20 | XPathNavigator methodNode = _xmlComments.GetMethodNode(actionMeta.ActionMethodInfo); 21 | if (methodNode == null) 22 | { 23 | return; 24 | } 25 | 26 | parameterDoc.Description = _xmlComments.GetMethodParamComment(methodNode, parameterMeta.ParameterName); 27 | } 28 | } -------------------------------------------------------------------------------- /netfusion/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | [*] 3 | 4 | resharper_replace_with_primary_constructor_parameter_highlighting=none 5 | resharper_suggest_var_or_type_simple_types_highlighting=none 6 | resharper_suggest_var_or_type_built_in_types_highlighting=none 7 | resharper_unused_member_global_highlighting=none 8 | resharper_class_never_instantiated_global_highlighting=none 9 | resharper_property_can_be_made_init_only_global_highlighting=none 10 | resharper_auto_property_can_be_made_get_only_global_highlighting=none 11 | resharper_collection_never_updated_global_highlighting=none 12 | resharper_unused_auto_property_accessor_global_highlighting=none 13 | resharper_unused_method_return_value_global_highlighting=none 14 | resharper_unused_member_in_super_global_highlighting=none 15 | resharper_suggest_var_or_type_elsewhere_highlighting=none 16 | resharper_member_can_be_private_global_highlighting=none 17 | resharper_unused_type_global_highlighting=none 18 | resharper_invert_if_highlighting=none 19 | resharper_member_can_be_protected_global_highlighting=none 20 | resharper_convert_if_statement_to_switch_statement_highlighting=none 21 | resharper_collection_never_queried_global_highlighting=none 22 | resharper_member_can_be_made_static_global_highlighting=none -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Redis/Plugin/Settings/RedisSettings.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Common.Base.Validation; 2 | using NetFusion.Core.Settings; 3 | 4 | namespace NetFusion.Integration.Redis.Plugin.Settings 5 | { 6 | /// 7 | /// Settings used to connect to a named set of Redis servers. 8 | /// 9 | [ConfigurationSection("netfusion:redis")] 10 | public class RedisSettings : IAppSettings, 11 | IValidatableType 12 | { 13 | public IDictionary Connections { get; set; } = new Dictionary(); 14 | 15 | /// 16 | /// The configuration represents a collection of items by keyed named. 17 | /// Updates the name on each item to that of the key specified within 18 | /// the configuration. 19 | /// 20 | public void SetNamedConfigurations() 21 | { 22 | foreach (var (name, conn) in Connections) 23 | { 24 | conn.Name = name; 25 | } 26 | } 27 | 28 | public void Validate(IObjectValidator validator) 29 | { 30 | validator.AddChildren(Connections.Values); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /netfusion/src/Core/NetFusion.Core.UnitTests/Bootstrap/Mocks/MockPluginModules.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Core.Bootstrap.Plugins; 2 | 3 | namespace NetFusion.Core.UnitTests.Bootstrap.Mocks; 4 | 5 | public abstract class MockPluginModule : PluginModule 6 | { 7 | public bool IsStarted { get; private set; } 8 | public bool IsStopped { get; private set; } 9 | 10 | protected override Task OnStartModuleAsync(IServiceProvider services) 11 | { 12 | IsStarted = true; 13 | 14 | return base.OnStartModuleAsync(services); 15 | } 16 | 17 | protected override Task OnStopModuleAsync(IServiceProvider services) 18 | { 19 | IsStopped = true; 20 | 21 | return base.OnStopModuleAsync(services); 22 | } 23 | } 24 | 25 | public interface IMockPluginOneModule : IPluginModuleService; 26 | 27 | public class MockPluginOneModule : MockPluginModule, 28 | IMockPluginOneModule; 29 | 30 | public class MockPluginTwoModule : MockPluginModule; 31 | 32 | public class MockPluginThreeModule : MockPluginModule; 33 | 34 | public class MockLoggingModule : MockPluginModule 35 | { 36 | public override void Log(IDictionary moduleLog) 37 | { 38 | moduleLog["Log-Msg"] = "Module-Added-Log"; 39 | } 40 | } -------------------------------------------------------------------------------- /netfusion/src/Web/NetFusion.Web.Rest.Client/Settings/IRequestSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http; 2 | 3 | namespace NetFusion.Web.Rest.Client.Settings; 4 | 5 | /// 6 | /// Represents settings to be applied to sent HTTP requests. 7 | /// 8 | public interface IRequestSettings 9 | { 10 | /// 11 | /// Headers to be added to the request message. 12 | /// 13 | RequestHeaders Headers { get; } 14 | 15 | /// 16 | /// Query string values to be added to the request URI. 17 | /// 18 | QueryString QueryString { get; } 19 | 20 | /// 21 | /// Applies the settings to the provided request message. 22 | /// 23 | /// Request message to apply settings. 24 | void Apply(HttpRequestMessage requestMessage); 25 | 26 | /// 27 | /// Returns a new settings instance with all provided request settings 28 | /// merged into a new instance of the current. 29 | /// 30 | /// New merged request settings instance. 31 | /// The settings to merge. 32 | IRequestSettings GetMerged(IRequestSettings requestSettings); 33 | } -------------------------------------------------------------------------------- /netfusion/src/Integration/NetFusion.Integration.Bus/Strategies/IBusEntityPublishStrategy.cs: -------------------------------------------------------------------------------- 1 | using NetFusion.Messaging.Types.Contracts; 2 | 3 | namespace NetFusion.Integration.Bus.Strategies; 4 | 5 | /// 6 | /// Strategy invoked during the publishing of a message and defines how a 7 | /// specific message type is published it an associated service-bus entity. 8 | /// 9 | public interface IBusEntityPublishStrategy : IBusEntityStrategy 10 | { 11 | /// 12 | /// Determines if the strategy knows how to publish a specific message type. 13 | /// 14 | /// The type of the message being published. 15 | /// True if the strategy is associated with the messaged. Otherwise, false. 16 | public bool CanPublishMessageType(Type messageType); 17 | 18 | /// 19 | /// Called to send the message to its corresponding service-bus defined entity. 20 | /// 21 | /// The message to be sent. 22 | /// Cancellation token. 23 | /// Future Result. 24 | Task SendToEntityAsync(IMessage message, CancellationToken cancellationToken); 25 | } --------------------------------------------------------------------------------