예제 #1
0
        private IEnumerable <string> ValidateFixedSettings()
        {
            string repoType = _settings.CertificateStore?.Repository?.Type;

            if (!GenericTypeBuilder.CanResolveTypeThatImplements <ICertificateRepository>(repoType))
            {
                yield return($"Certificate store type: {repoType} cannot be resolved");
            }
        }
예제 #2
0
        private static T CreateInstance <T>(string typeString, params object[] args) where T : class
        {
            if (!GenericTypeBuilder.CanResolveTypeThatImplements <IStep>(typeString))
            {
                throw new InvalidOperationException(
                          $"Cannot resolve a valid {nameof(IStep)} implementation for the {typeString} fully-qualified assembly name");
            }

            return(GenericTypeBuilder.FromType(typeString).SetArgs(args).Build <T>());
        }
예제 #3
0
        private static ICertificateRepository ResolveCertificateRepository(string typeString)
        {
            if (!GenericTypeBuilder.CanResolveTypeThatImplements <ICertificateRepository>(typeString))
            {
                throw new InvalidOperationException(
                          $"Cannot resolve a valid {nameof(ICertificateRepository)} implementation for the {typeString} fully-qualified assembly name");
            }

            return(GenericTypeBuilder
                   .FromType(typeString)
                   .Build <ICertificateRepository>());
        }
예제 #4
0
        private static IEnumerable <string> ValidateAgentSettings(AgentSettings settings)
        {
            if (settings.Receiver?.Type == null)
            {
                yield return($"Agent: {settings.Name} hasn't got a Receiver type configured");
            }
            else if (!GenericTypeBuilder.CanResolveTypeThatImplements <IReceiver>(settings.Receiver.Type))
            {
                yield return($"Agent: {settings.Name} Receiver type: {settings.Receiver.Type} cannot be resolved");
            }

            if (settings.Transformer?.Type == null)
            {
                yield return($"Agent: {settings.Name} hasn't got a Transformer type configured");
            }
            else if (!GenericTypeBuilder.CanResolveTypeThatImplements <ITransformer>(settings.Transformer.Type))
            {
                yield return($"Agent: {settings.Name} Transformer type: {settings.Transformer.Type} cannot be resolved");
            }

            if (settings.StepConfiguration?.NormalPipeline == null)
            {
                yield return($"Agent: {settings.Name} hasn't got a Steps.NormalPipeline Step type(s) configured");
            }
            else
            {
                foreach (Step s in settings.StepConfiguration.NormalPipeline)
                {
                    if (!GenericTypeBuilder.CanResolveTypeThatImplements <IStep>(s.Type))
                    {
                        yield return($"Agent: {settings.Name} has a Step in the NormalPipeline with type: {s.Type ?? "<null>"} that cannot be resolved");
                    }
                }
            }

            if (settings.StepConfiguration?.ErrorPipeline != null)
            {
                foreach (Step s in settings.StepConfiguration.ErrorPipeline)
                {
                    if (!GenericTypeBuilder.CanResolveTypeThatImplements <IStep>(s.Type))
                    {
                        yield return($"Agent: {settings.Name} has a Step in the NormalPipeline with type: {s.Type ?? "<null>"} that cannot be resolved");
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Build the <see cref="IReceiver"/> implementation
        /// </summary>
        /// <returns></returns>
        public IReceiver Build()
        {
            if (!GenericTypeBuilder.CanResolveTypeThatImplements <IReceiver>(_settingReceiver.Type))
            {
                throw new InvalidOperationException(
                          $"Cannot resolve a valid {nameof(IReceiver)} implementation for the {_settingReceiver.Type} fully-qualified assembly name");
            }

            var receiver = GenericTypeBuilder.FromType(_settingReceiver.Type).Build <IReceiver>();

            if (_settingReceiver.Setting != null)
            {
                receiver.Configure(_settingReceiver.Setting);
            }

            return(receiver);
        }
        private static IDynamicDiscoveryProfile ResolveDynamicDiscoveryProfile(string smpProfile)
        {
            if (smpProfile == null)
            {
                Logger.Debug($"SendingPMode doesn't specify DynamicDiscovery.SmpProfile element, using default: {nameof(LocalDynamicDiscoveryProfile)}");
                return(new LocalDynamicDiscoveryProfile());
            }

            if (!GenericTypeBuilder.CanResolveTypeThatImplements <IDynamicDiscoveryProfile>(smpProfile))
            {
                Logger.Error(
                    "SendingPMode.DynamicDiscovery.SmpProfile element doesn't have a fully-qualified assembly name "
                    + $"that can be used to resolve a instance that implements the {nameof(IDynamicDiscoveryProfile)} interface");

                throw new InvalidOperationException(
                          "Dynamic Discovery process was not correctly configured");
            }

            Logger.Debug($"SendingPMode specifies a DynamicDiscovery.SmpProfile element, resolve using: {smpProfile}");
            return(GenericTypeBuilder
                   .FromType(smpProfile)
                   .Build <IDynamicDiscoveryProfile>());
        }