Summary

Class:CBAM.HTTP.SimpleHTTPConfiguration
Assembly:CBAM.HTTP.Implementation
File(s):/repo-dir/contents/Source/Code/CBAM.HTTP.Implementation/ConnectionConfiguration.cs
Covered lines:3
Uncovered lines:0
Coverable lines:3
Total lines:140
Line coverage:100%

Coverage History

File(s)

/repo-dir/contents/Source/Code/CBAM.HTTP.Implementation/ConnectionConfiguration.cs

#LineLine coverage
 1/*
 2 * Copyright 2017 Stanislav Muhametsin. All rights Reserved.
 3 *
 4 * Licensed  under the  Apache License,  Version 2.0  (the "License");
 5 * you may not use  this file  except in  compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 *   http://www.apache.org/licenses/LICENSE-2.0
 9 *
 10 * Unless required by applicable law or agreed to in writing, software
 11 * distributed  under the  License is distributed on an "AS IS" BASIS,
 12 * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
 13 * implied.
 14 *
 15 * See the License for the specific language governing permissions and
 16 * limitations under the License.
 17 */
 18using CBAM.HTTP;
 19using IOUtils.Network.Configuration;
 20using System;
 21using System.Collections.Generic;
 22using System.Net;
 23using System.Text;
 24using UtilPack;
 25
 26namespace CBAM.HTTP
 27{
 28   /// <summary>
 29   /// This class extends <see cref="NetworkConnectionCreationInfo{TCreationData, TConnectionConfiguration, TInitializat
 30   /// </summary>
 31   public sealed class HTTPNetworkCreationInfo : NetworkConnectionCreationInfo<HTTPNetworkCreationInfoData, HTTPConnecti
 32   {
 33      /// <summary>
 34      /// Creates new instance of <see cref="HTTPNetworkCreationInfo"/> with given <see cref="HTTPNetworkCreationInfoDat
 35      /// </summary>
 36      /// <param name="data">The <see cref="HTTPNetworkCreationInfoData"/>.</param>
 37      /// <exception cref="ArgumentNullException">If <paramref name="data"/> is <c>null</c>.</exception>
 38      public HTTPNetworkCreationInfo(
 39         HTTPNetworkCreationInfoData data
 40         ) : base( data )
 41      {
 42      }
 43
 44   }
 45
 46   /// <summary>
 47   /// This class extends <see cref="NetworkConnectionCreationInfoData{TConnectionConfiguration, TInitializationConfigur
 48   /// </summary>
 49   public sealed class HTTPNetworkCreationInfoData : NetworkConnectionCreationInfoData<HTTPConnectionConfiguration, HTTP
 50   {
 51
 52   }
 53
 54   /// <summary>
 55   /// This class extends <see cref="NetworkConnectionConfiguration"/> to provide detailed and highly customizable confi
 56   /// </summary>
 57   public sealed class HTTPConnectionConfiguration : NetworkConnectionConfiguration
 58   {
 59
 60   }
 61
 62   /// <summary>
 63   /// This class extends <see cref="NetworkInitializationConfiguration{TProtocolConfiguration, TPoolingConfiguration}"/
 64   /// </summary>
 65   public sealed class HTTPInitializationConfiguration : NetworkInitializationConfiguration<HTTPProtocolConfiguration, H
 66   {
 67
 68   }
 69
 70   /// <summary>
 71   /// This class contains information about HTTP protocol initialization.
 72   /// </summary>
 73   public sealed class HTTPProtocolConfiguration
 74   {
 75   }
 76
 77   /// <summary>
 78   /// This class extends <see cref="NetworkPoolingConfiguration"/>.
 79   /// </summary>
 80   public sealed class HTTPPoolingConfiguration : NetworkPoolingConfiguration
 81   {
 82
 83   }
 84
 85   /// <summary>
 86   /// This class contains properties for simplistic HTTP configuration.
 87   /// This class may also be used when (de)serializing configuration.
 88   /// </summary>
 89   /// <seealso cref="Implementation.HTTPSimpleConfigurationPoolProvider{TRequestMetaData}"/>
 90   public class SimpleHTTPConfiguration
 91   {
 92      /// <summary>
 93      /// Gets or sets the host name for the remote endpoint.
 94      /// </summary>
 95      /// <value>The host name for the remote endpoint.</value>
 96      /// <remarks>
 97      /// This may be either stringified <see cref="IPAddress"/> or actual hostname (which will result in DNS resolve).
 98      /// </remarks>
 899      public String Host { get; set; }
 100
 101      /// <summary>
 102      /// Gets or sets the port number for the remote endpoint.
 103      /// </summary>
 104      /// <value>The port number for the remote endpoint.</value>
 6105      public Int32 Port { get; set; }
 106
 107      /// <summary>
 108      /// Gets or sets the value indicating whether the connection is secured by SSL.
 109      /// </summary>
 110      /// <value>The value indicating whether the connection is secured by SSL.</value>
 6111      public Boolean IsSecure { get; set; }
 112   }
 113
 114
 115}
 116
 117public static partial class E_CBAM
 118{
 119   /// <summary>
 120   /// This is helper method to create a new <see cref="HTTPNetworkCreationInfo"/> from this <see cref="SimpleHTTPConfig
 121   /// </summary>
 122   /// <param name="simpleConfig">This <see cref="SimpleHTTPConfiguration"/>.</param>
 123   /// <returns>A new instance of <see cref="HTTPNetworkCreationInfo"/> which is configured as this <see cref="SimpleHTT
 124   /// <exception cref="NullReferenceException">If this <see cref="SimpleHTTPConfiguration"/> is <c>null</c>.</exception
 125   public static HTTPNetworkCreationInfo CreateNetworkCreationInfo( this SimpleHTTPConfiguration simpleConfig )
 126   {
 127      var isSecure = simpleConfig.IsSecure;
 128      var port = simpleConfig.Port;
 129      return new HTTPNetworkCreationInfo( new HTTPNetworkCreationInfoData()
 130      {
 131         Connection = new HTTPConnectionConfiguration()
 132         {
 133            ConnectionSSLMode = isSecure ? ConnectionSSLMode.Required : ConnectionSSLMode.NotRequired,
 134            Host = simpleConfig.Host,
 135            Port = port <= 0 ? ( isSecure ? 443 : 80 ) : port
 136         },
 137
 138      } );
 139   }
 140}

Methods/Properties

Host()
Port()
IsSecure()