Ejemplo n.º 1
0
        /// <summary>
        /// Gets the endpoints configuration.
        /// </summary>
        /// <param name="endpointsNode">The endpoints node.</param>
        /// <returns></returns>
        /// <exception cref="System.InvalidOperationException">
        /// The 'baseUrl' value should be a valid URL.
        /// </exception>
        protected virtual EndpointsConfiguration GetEndpointsConfiguration(XmlNode endpointsNode)
        {
            var baseUrlNode = endpointsNode.Attributes["baseUrl"];

            Assert.NotNull(baseUrlNode, "The 'baseUrl' attribute is required for the 'komfoSharp/services/endpoints' node.");
            Assert.NotNullOrEmpty(baseUrlNode.Value, "The 'baseUrl' value should be a valid URL.");

            Uri baseUrl;

            if (!Uri.TryCreate(baseUrlNode.Value, UriKind.Absolute, out baseUrl) || !(baseUrl.Scheme == Uri.UriSchemeHttp || baseUrl.Scheme == Uri.UriSchemeHttps))
            {
                throw new InvalidOperationException("The 'baseUrl' value should be a valid URL.");
            }

            var endpoints = new List <EndpointBase>();

            foreach (XmlNode node in endpointsNode.ChildNodes)
            {
                var endpoint = this.DeserializeEndpoint(node);
                endpoints.Add(endpoint);
            }

            var endpointsConfiguration = new EndpointsConfiguration(endpoints, new Uri(baseUrlNode.Value));

            return(endpointsConfiguration);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KomfoProvider" /> class.
 /// </summary>
 /// <param name="configurationProvider">The configuration provider.</param>
 public KomfoProvider(IConfigurationProvider configurationProvider)
 {
     this.endpointsConfiguration = configurationProvider.GetConfiguration().EndpointsConfiguration;
 }
Ejemplo n.º 3
0
 public EndpointRoutingConvention(IOptions <EndpointsConfiguration> endpointsConfiguration)
 {
     this.endpointsConfiguration = endpointsConfiguration.Value;
 }