| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Configuration |
| | | 8 | | { |
| | | 9 | | internal class ServiceConfigurationDelegateHolder |
| | | 10 | | { |
| | 1140 | 11 | | private readonly List<Action<ServiceHostBase>> _configDelegates = new List<Action<ServiceHostBase>>(); |
| | 1140 | 12 | | private readonly List<Action<ServiceOptions>> _serviceOptionsDelegates = new List<Action<ServiceOptions>>(); |
| | | 13 | | internal void AddConfigDelegate(Action<ServiceHostBase> func) |
| | | 14 | | { |
| | 59 | 15 | | _configDelegates.Add(func); |
| | 59 | 16 | | } |
| | | 17 | | |
| | | 18 | | internal void Configure(ServiceHostBase host) |
| | | 19 | | { |
| | 2428 | 20 | | foreach (Action<ServiceHostBase> del in _configDelegates) |
| | | 21 | | { |
| | 62 | 22 | | del(host); |
| | | 23 | | } |
| | 1152 | 24 | | } |
| | | 25 | | |
| | | 26 | | internal void AddServiceOptionsDelegate(Action<ServiceOptions> options) |
| | | 27 | | { |
| | 35 | 28 | | _serviceOptionsDelegates.Add(options); |
| | 35 | 29 | | } |
| | | 30 | | |
| | | 31 | | internal bool ApplyOptions(ServiceOptions options) |
| | | 32 | | { |
| | 1117 | 33 | | if (_serviceOptionsDelegates.Count == 0) return false; |
| | 140 | 34 | | foreach(Action<ServiceOptions> del in _serviceOptionsDelegates) |
| | | 35 | | { |
| | 35 | 36 | | del(options); |
| | | 37 | | } |
| | | 38 | | |
| | 35 | 39 | | return true; |
| | | 40 | | } |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | // Used by ConfigureAllServiceHostBase |
| | | 44 | | internal class AllServicesConfigurationDelegateHolder : ServiceConfigurationDelegateHolder { } |
| | | 45 | | |
| | | 46 | | internal class ServiceConfigurationDelegateHolder<TService> : ServiceConfigurationDelegateHolder |
| | | 47 | | where TService : class |
| | | 48 | | { |
| | | 49 | | |
| | | 50 | | } |
| | | 51 | | } |