/// <summary> /// Validates the specified <see cref="IHyperNodeConfiguration"/> object. /// </summary> /// <param name="config"><see cref="IHyperNodeConfiguration"/> object to validate.</param> public void ValidateConfiguration(IHyperNodeConfiguration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } var configClassName = config.GetType().FullName; if (string.IsNullOrWhiteSpace(config.HyperNodeName)) { RaiseValidationEvent( new HyperNodeConfigurationException($"The HyperNodeName property is required for {configClassName}.") ); } // TaskIdProviderType is not required, but if it is specified, it must implement the correct interface if (!string.IsNullOrWhiteSpace(config.TaskIdProviderType)) { ValidateTypeImplementsInterface(config.TaskIdProviderType, typeof(ITaskIdProvider)); } // HyperNodeEventHandlerType is not required, but if it is specified, it must implement the correct interface if (!string.IsNullOrWhiteSpace(config.HyperNodeEventHandlerType)) { ValidateTypeImplementsInterface(config.HyperNodeEventHandlerType, typeof(IHyperNodeEventHandler)); } if (config.ActivityMonitors != null) { foreach (var activityMonitor in config.ActivityMonitors) { ValidateConfiguration(activityMonitor); } } if (config.SystemCommands != null) { foreach (var systemCommand in config.SystemCommands) { ValidateConfiguration(systemCommand); } } if (config.CommandModules != null) { // RequestSerializerType property is not required at the collection level, but if it is specified, it must implement the correct interface if (!string.IsNullOrWhiteSpace(config.CommandModules.RequestSerializerType)) { ValidateTypeImplementsInterface(config.CommandModules.RequestSerializerType, typeof(ICommandRequestSerializer)); } // ResponseSerializerType property is not required at the collection level, but if it is specified, it must implement the correct interface if (!string.IsNullOrWhiteSpace(config.CommandModules.ResponseSerializerType)) { ValidateTypeImplementsInterface(config.CommandModules.ResponseSerializerType, typeof(ICommandResponseSerializer)); } foreach (var commandModule in config.CommandModules) { ValidateConfiguration(commandModule); } } }