/// <summary>
        /// The create service host.
        /// </summary>
        /// <param name="serviceType">
        /// The service type.
        /// </param>
        /// <param name="baseAddresses">
        /// The base addresses.
        /// </param>
        /// <returns>
        /// The <see cref="ServiceHost"/>.
        /// </returns>
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            if (serviceType == typeof(SubscriptionLookupService))
            {
                var serviceSettings = new LookupServiceSettings
                {
                    MdmApplicationId       = this.mdmApplicationId,
                    PublicationId          = this.publicationId,
                    PublicationDescription = this.publicationDescription,
                    PublicationName        = this.publicationName,
                    PublicationOptinLink   = this.publicationOptinLink
                };

                return(new LookupServiceHost(this.usersDal, serviceSettings, serviceType, baseAddresses));
            }

            if (serviceType == typeof(UnsubscribeService))
            {
                var serviceSettings = new UnsubscribeServiceSettings {
                    MdmApplicationId = this.mdmApplicationId
                };
                return(new UnsubscribeServiceHost(this.hcpCommandsQueue, serviceSettings, serviceType, baseAddresses));
            }

            if (serviceType == typeof(SuppressUserService))
            {
                return(new SuppressUserServiceHost(this.hcpCommandsQueue, serviceType, baseAddresses));
            }

            string errorMsg = string.Format("service type: {0} is unknown service type", serviceType.FullName);

            Log.Error(errorMsg);
            throw new ArgumentException(errorMsg, "serviceType");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UnsubscribeServiceInstanceProvider"/> class.
        /// </summary>
        /// <param name="hcpCommandsQueue">
        /// The hcp commands queue
        /// </param>
        /// <param name="serviceSettings">
        /// The unsubscribe service settings.
        /// </param>
        public UnsubscribeServiceInstanceProvider(IHcpCommandsQueue hcpCommandsQueue, UnsubscribeServiceSettings serviceSettings)
        {
            if (hcpCommandsQueue == null)
            {
                throw new ArgumentNullException("hcpCommandsQueue");
            }

            if (serviceSettings == null)
            {
                throw new ArgumentNullException("serviceSettings");
            }

            this.unsubscribeServiceSettings = serviceSettings;
            this.hcpCommandsQueue           = hcpCommandsQueue;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UnsubscribeServiceHost"/> class.
        /// </summary>
        /// <param name="hcpCommandsQueue">
        /// The hcp commands queue
        /// </param>
        /// <param name="serviceSettings">
        /// The unsubscribe service settings.
        /// </param>
        /// <param name="serviceType">
        /// The service type.
        /// </param>
        /// <param name="baseAddresses">
        /// The base addresses.
        /// </param>
        public UnsubscribeServiceHost(IHcpCommandsQueue hcpCommandsQueue, UnsubscribeServiceSettings serviceSettings, Type serviceType, params Uri[] baseAddresses)
            : base(serviceType, baseAddresses)
        {
            if (hcpCommandsQueue == null)
            {
                throw new ArgumentNullException("hcpCommandsQueue");
            }

            if (serviceSettings == null)
            {
                throw new ArgumentNullException("serviceSettings");
            }

            foreach (ContractDescription cd in this.ImplementedContracts.Values)
            {
                cd.Behaviors.Add(new UnsubscribeServiceInstanceProvider(hcpCommandsQueue, serviceSettings));
            }
        }