Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyChatServiceInstanceProvider"/> class.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger"/> instance.</param>
        /// <param name="hostFactory">The <see cref="MyChatServiceHostFactory"/> instance.</param>
        public MyChatServiceInstanceProvider(ILogger logger, MyChatServiceHostFactory hostFactory)
        {
            if (hostFactory == null)
            {
                throw new ArgumentNullException(paramName: nameof(hostFactory));
            }

            this.logger = logger ?? throw new ArgumentNullException(paramName: nameof(logger));
            this.notificationManager = new NotificationManager(
                logger: logger,
                dataStore: dataStore,
                port: Settings.Default.NotificationManagerPort,
                uri: Settings.Default.NotificationManagerUri);

            hostFactory.RegisterToDisposition(@object: this.notificationManager);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyChatServiceHost"/> class.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger"/> instance.</param>
        /// <param name="hostFactory">The <see cref="MyChatServiceHostFactory"/> instance.</param>
        /// <param name="baseAddresses">The base addresses.</param>
        public MyChatServiceHost(ILogger logger, MyChatServiceHostFactory hostFactory, params Uri[] baseAddresses)
            : base(serviceType: typeof(MyChatService), baseAddresses: baseAddresses)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(paramName: nameof(logger));
            }

            if (hostFactory == null)
            {
                throw new ArgumentNullException(paramName: nameof(hostFactory));
            }

            var instanceProvider = new MyChatServiceInstanceProvider(logger: logger, hostFactory: hostFactory);

            foreach (var cd in this.ImplementedContracts.Values)
            {
                cd.Behaviors.Add(item: instanceProvider);
            }
        }