/// <summary>
        /// Resolves the preferred binding type into an actual binding. This algorithm can be improved in the future to be have multiple bindings
        /// </summary>
        /// <param name="binding">The preferred binding type.</param>
        /// <returns></returns>
        private Binding ResolveBinding(PreferredBinding binding)
        {
            var effectiveBinding = _defaultBinding;

            switch (binding)
            {
            case PreferredBinding.NoPreference:

                effectiveBinding = _defaultBinding;
                break;

            case PreferredBinding.Http:
                if (_defaultBinding.GetType() == typeof(WSHttpBinding))
                {
                    effectiveBinding = _defaultBinding;
                }
                break;


            case PreferredBinding.NetTcp:
                if (_defaultBinding.GetType() == typeof(WSHttpBinding))
                {
                    effectiveBinding = _defaultBinding;
                }
                break;
            }

            return(effectiveBinding);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WcfServiceConfigurationSet"/> class.
        /// </summary>
        /// <param name="address">The relative address.</param>
        /// <param name="binding">The preferred binding (if available.</param>
        /// <param name="contract">The contract.</param>
        /// <remarks></remarks>
        public WcfServiceConfigurationSet(Uri address, PreferredBinding binding, Type contract)
        {
            Address = address;
            Binding = binding;
            ContractType = contract;

        }
        /// <summary>
        /// Adds the configuration set.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <param name="binding">The binding.</param>
        /// <param name="contract">The contract.</param>
        public IWcfServiceConfigurationProvider AddConfigurationSet(Uri address, PreferredBinding binding, Type contract)
        {
           // if(_defaultBinding == null || _defaultBaseAddress == null ) throw new ApplicationException("WithDefaultBinding and WithBaseAddress need to be called first.");
            
            _configurationSets.Add(new WcfServiceConfigurationSet(address, binding, contract));

            return this;
        }
        /// <summary>
        /// Adds the configuration set.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <param name="binding">The binding.</param>
        /// <param name="contract">The contract.</param>
        public IWcfServiceConfigurationProvider AddConfigurationSet(Uri address, PreferredBinding binding, Type contract)
        {
            // if(_defaultBinding == null || _defaultBaseAddress == null ) throw new ApplicationException("WithDefaultBinding and WithBaseAddress need to be called first.");

            _configurationSets.Add(new WcfServiceConfigurationSet(address, binding, contract));

            return(this);
        }
        /// <summary>
        /// Resolves the preferred binding type into an actual binding. This algorithm can be improved in the future to be have multiple bindings 
        /// </summary>
        /// <param name="binding">The preferred binding type.</param>
        /// <returns></returns>
        private Binding ResolveBinding(PreferredBinding binding)
        {
            var effectiveBinding = _defaultBinding;

            switch (binding)
            {
                case PreferredBinding.NoPreference:

                    effectiveBinding = _defaultBinding;
                    break;

                case PreferredBinding.Http:
                    if (_defaultBinding.GetType() == typeof (WSHttpBinding)) effectiveBinding =  _defaultBinding;
                    break;


                case PreferredBinding.NetTcp:
                    if (_defaultBinding.GetType() == typeof(WSHttpBinding)) effectiveBinding = _defaultBinding;
                    break;
            }

            return effectiveBinding;
        }
 /// <summary>
 /// Adds the configuration set. Defaults the Uri to blank. 
 /// </summary>
 /// <param name="binding">The binding.</param>
 /// <param name="contract">The contract.</param>
 public IWcfServiceConfigurationProvider AddConfigurationSet(PreferredBinding binding, Type contract)
 {
     return AddConfigurationSet(new Uri("", UriKind.Relative), binding, contract);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AutoHostingWcfServiceAttribute"/> class.
 /// </summary>
 /// <param name="preferredBinding">The default binding.</param>
 public AutoHostingWcfServiceAttribute(PreferredBinding preferredBinding)
 {
     _preferredBinding = preferredBinding;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WcfServiceConfigurationSet"/> class.
 /// </summary>
 /// <param name="address">The relative address.</param>
 /// <param name="binding">The preferred binding (if available.</param>
 /// <param name="contract">The contract.</param>
 /// <remarks></remarks>
 public WcfServiceConfigurationSet(Uri address, PreferredBinding binding, Type contract)
 {
     Address      = address;
     Binding      = binding;
     ContractType = contract;
 }
 /// <summary>
 /// Adds the configuration set. Defaults the Uri to blank.
 /// </summary>
 /// <param name="binding">The binding.</param>
 /// <param name="contract">The contract.</param>
 public IWcfServiceConfigurationProvider AddConfigurationSet(PreferredBinding binding, Type contract)
 {
     return(AddConfigurationSet(new Uri("", UriKind.Relative), binding, contract));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AutoHostingWcfServiceAttribute"/> class.
 /// </summary>
 /// <param name="preferredBinding">The default binding.</param>
 public AutoHostingWcfServiceAttribute(PreferredBinding preferredBinding)
 {
     _preferredBinding = preferredBinding;
 }