コード例 #1
0
        public IEndpoint GetEndpoint(IConfigurationSection configSection)
        {
            var endpointTypeName = configSection.GetSection("Type").Value;

            if (string.IsNullOrWhiteSpace(endpointTypeName))
            {
                throw new InvalidOperationException($"Missing Type in section {configSection.Path}.");
            }

            var endpoint = _customActivator.Activate <IEndpoint>(endpointTypeName, configSection);

            SetSerializer(endpoint, configSection.GetSection("Serializer"));

            configSection.Bind(endpoint);

            return(endpoint);
        }
コード例 #2
0
        public ErrorPolicyBase GetErrorPolicy(IConfigurationSection configSection)
        {
            var policyType = configSection.GetSection("Type").Value;

            if (string.IsNullOrWhiteSpace(policyType))
            {
                throw new InvalidOperationException($"Missing Type in section {configSection.Path}.");
            }

            var errorPolicy = _customActivator.Activate <ErrorPolicyBase>(
                configSection,
                policyType,
                policyType + "Policy",
                policyType + "ErrorPolicy",
                policyType + "MessageErrorPolicy");

            configSection.Bind(errorPolicy);

            SetApplyTo(errorPolicy, configSection.GetSection("ApplyTo"));
            SetExclude(errorPolicy, configSection.GetSection("Exclude"));
            SetMaxFailedAttempts(errorPolicy, configSection.GetSection("MaxFailedAttempts"));

            return(errorPolicy);
        }