< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.DispatchRuntime
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/DispatchRuntime.cs
Line coverage
68%
Covered lines: 218
Uncovered lines: 101
Coverable lines: 319
Total lines: 863
Line coverage: 68.3%
Branch coverage
50%
Covered branches: 31
Total branches: 62
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/DispatchRuntime.cs

#LineLine coverage
 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
 4using System;
 5using System.Collections.ObjectModel;
 6using System.Threading;
 7using System.Threading.Tasks;
 8using CoreWCF.Channels;
 9using CoreWCF.Collections.Generic;
 10using CoreWCF.Description;
 11using CoreWCF.Diagnostics;
 12using CoreWCF.IdentityModel.Policy;
 13using CoreWCF.Runtime;
 14using Microsoft.AspNetCore.Authorization;
 15
 16namespace CoreWCF.Dispatcher
 17{
 18    public sealed class DispatchRuntime
 19    {
 20        private ServiceAuthenticationManager _serviceAuthenticationManager;
 21        private ServiceAuthorizationManager _serviceAuthorizationManager;
 22        private ReadOnlyCollection<IAuthorizationPolicy> _externalAuthorizationPolicies;
 23        private IAuthorizationService _authorizationService;
 24
 25        //AuditLogLocation securityAuditLogLocation;
 26        private ConcurrencyMode _concurrencyMode;
 27        private bool _ensureOrderedDispatch;
 28
 29        //bool suppressAuditFailure;
 30        //AuditLevel serviceAuthorizationAuditLevel;
 31        //AuditLevel messageAuthenticationAuditLevel;
 32        private bool _automaticInputSessionShutdown;
 33        private readonly ChannelDispatcher _channelDispatcher;
 34        private IInstanceProvider _instanceProvider;
 35        private IInstanceContextProvider _instanceContextProvider;
 36        private InstanceContext _singleton;
 37        private bool _ignoreTransactionMessageProperty;
 38        private readonly OperationCollection _operations;
 39        private IDispatchOperationSelector _operationSelector;
 40        private ImmutableDispatchRuntime _runtime;
 41        private bool _isExternalPoliciesSet;
 42        private bool _isAuthorizationManagerSet;
 43        private SynchronizationContext _synchronizationContext;
 44        private PrincipalPermissionMode _principalPermissionMode;
 45
 46        //object roleProvider;
 47        private Type _type;
 48        private DispatchOperation _unhandled;
 49        private bool _impersonateCallerForAllOperations;
 50        private bool _impersonateOnSerializingReply;
 51        private readonly SharedRuntimeState _shared;
 52        private bool _requireClaimsPrincipalOnOperationContext;
 53        private bool _supportsAuthorizationData;
 54
 55        internal DispatchRuntime(EndpointDispatcher endpointDispatcher)
 66456            : this(new SharedRuntimeState(true))
 57        {
 66458            EndpointDispatcher = endpointDispatcher ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(
 59            Fx.Assert(_shared.IsOnServer, "Server constructor called on client?");
 66460        }
 61
 62        internal DispatchRuntime(ClientRuntime proxyRuntime, SharedRuntimeState shared)
 063            : this(shared)
 64        {
 065            ClientRuntime = proxyRuntime ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(prox
 066            _instanceProvider = new CallbackInstanceProvider();
 067            _channelDispatcher = new ChannelDispatcher(shared);
 068            _instanceContextProvider = InstanceContextProviderBase.GetProviderForMode(InstanceContextMode.PerSession, th
 69
 70            Fx.Assert(!shared.IsOnServer, "Client constructor called on server?");
 071        }
 72
 66473        private DispatchRuntime(SharedRuntimeState shared)
 74        {
 66475            _shared = shared;
 76
 66477            _operations = new OperationCollection(this);
 78
 66479            InputSessionShutdownHandlers = NewBehaviorCollection<IInputSessionShutdown>();
 66480            MessageInspectors = NewBehaviorCollection<IDispatchMessageInspector>();
 66481            InstanceContextInitializers = NewBehaviorCollection<IInstanceContextInitializer>();
 66482            _synchronizationContext = ThreadBehavior.GetCurrentSynchronizationContext();
 66483            _automaticInputSessionShutdown = true;
 66484            _principalPermissionMode = ServiceAuthorizationBehavior.DefaultPrincipalPermissionMode;
 66485            _unhandled = new DispatchOperation(this, "*", MessageHeaders.WildcardAction, MessageHeaders.WildcardAction)
 66486            {
 66487                InternalFormatter = MessageOperationFormatter.Instance,
 66488                InternalInvoker = new UnhandledActionInvoker(this)
 66489            };
 66490        }
 91
 92        public IInstanceContextProvider InstanceContextProvider
 93        {
 94            get
 95            {
 637996                return _instanceContextProvider;
 97            }
 98
 99            set
 100            {
 664101                if (value == null)
 102                {
 0103                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 104                }
 105
 664106                lock (ThisLock)
 107                {
 664108                    InvalidateRuntime();
 664109                    _instanceContextProvider = value;
 664110                }
 664111            }
 112        }
 113
 114        public InstanceContext SingletonInstanceContext
 115        {
 845116            get { return _singleton; }
 117            set
 118            {
 125119                if (value == null)
 120                {
 0121                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 122                }
 123
 125124                lock (ThisLock)
 125                {
 125126                    InvalidateRuntime();
 125127                    _singleton = value;
 125128                }
 125129            }
 130        }
 131
 132        public ConcurrencyMode ConcurrencyMode
 133        {
 134            get
 135            {
 2981136                return _concurrencyMode;
 137            }
 138            set
 139            {
 664140                lock (ThisLock)
 141                {
 664142                    InvalidateRuntime();
 664143                    _concurrencyMode = value;
 664144                }
 664145            }
 146        }
 147
 148        public bool EnsureOrderedDispatch
 149        {
 150            get
 151            {
 2980152                return _ensureOrderedDispatch;
 153            }
 154            set
 155            {
 641156                lock (ThisLock)
 157                {
 641158                    InvalidateRuntime();
 641159                    _ensureOrderedDispatch = value;
 641160                }
 641161            }
 162        }
 163
 164        internal ReadOnlyCollection<IAuthorizationPolicy> ExternalAuthorizationPolicies
 165        {
 166            get
 167            {
 133168                return _externalAuthorizationPolicies;
 169            }
 170            set
 171            {
 26172                lock (ThisLock)
 173                {
 26174                    InvalidateRuntime();
 26175                    _externalAuthorizationPolicies = value;
 26176                    _isExternalPoliciesSet = true;
 26177                }
 26178            }
 179        }
 180
 181        public ServiceAuthenticationManager ServiceAuthenticationManager
 182        {
 183            get
 184            {
 0185                return _serviceAuthenticationManager;
 186            }
 187            set
 188            {
 0189                lock (ThisLock)
 190                {
 0191                    InvalidateRuntime();
 0192                    _serviceAuthenticationManager = value;
 0193                    RequiresAuthentication = true;
 0194                }
 0195            }
 196        }
 197
 198        public ServiceAuthorizationManager ServiceAuthorizationManager
 199        {
 200            get
 201            {
 133202                return _serviceAuthorizationManager;
 203            }
 204            set
 205            {
 5206                lock (ThisLock)
 207                {
 5208                    InvalidateRuntime();
 5209                    _serviceAuthorizationManager = value;
 5210                    _isAuthorizationManagerSet = true;
 5211                }
 5212            }
 213        }
 214
 215        [Obsolete("DispatchRuntime.AuthorizationService will be made internal in next major release.")]
 216        public IAuthorizationService AuthorizationService
 217        {
 0218            get => throw new NotSupportedException();
 0219            set => throw new NotSupportedException();
 220        }
 221
 222        // TODO: Make AuthorizationService property internal and replace get/set implementations with the 2 methods belo
 133223        internal IAuthorizationService GetAuthorizationService() => _authorizationService;
 224
 225        internal void SetAuthorizationService(IAuthorizationService authorizationService)
 226        {
 110227            lock (ThisLock)
 228            {
 110229                InvalidateRuntime();
 110230                _authorizationService = authorizationService;
 110231            }
 110232        }
 233
 234        public bool AutomaticInputSessionShutdown
 235        {
 516236            get { return _automaticInputSessionShutdown; }
 237            set
 238            {
 641239                lock (ThisLock)
 240                {
 641241                    InvalidateRuntime();
 641242                    _automaticInputSessionShutdown = value;
 641243                }
 641244            }
 245        }
 246
 247        public ChannelDispatcher ChannelDispatcher
 248        {
 2058249            get { return _channelDispatcher ?? EndpointDispatcher.ChannelDispatcher; }
 250        }
 251
 252        public ClientRuntime CallbackClientRuntime
 253        {
 254            get
 255            {
 524256                if (ClientRuntime == null)
 257                {
 505258                    lock (ThisLock)
 259                    {
 505260                        if (ClientRuntime == null)
 261                        {
 505262                            ClientRuntime = new ClientRuntime(this, _shared);
 263                        }
 505264                    }
 265                }
 266
 524267                return ClientRuntime;
 268            }
 269        }
 270
 3068271        public EndpointDispatcher EndpointDispatcher { get; }
 272
 273        public bool ImpersonateCallerForAllOperations
 274        {
 275            get
 276            {
 657277                return _impersonateCallerForAllOperations;
 278            }
 279            set
 280            {
 641281                lock (ThisLock)
 282                {
 641283                    InvalidateRuntime();
 641284                    _impersonateCallerForAllOperations = value;
 641285                }
 641286            }
 287        }
 288
 289        public bool ImpersonateOnSerializingReply
 290        {
 291            get
 292            {
 661293                return _impersonateOnSerializingReply;
 294            }
 295            set
 296            {
 641297                lock (ThisLock)
 298                {
 641299                    InvalidateRuntime();
 641300                    _impersonateOnSerializingReply = value;
 641301                }
 641302            }
 303        }
 304
 305        internal bool RequireClaimsPrincipalOnOperationContext
 306        {
 307            get
 308            {
 661309                return _requireClaimsPrincipalOnOperationContext;
 310            }
 311            set
 312            {
 481313                lock (ThisLock)
 314                {
 481315                    InvalidateRuntime();
 481316                    _requireClaimsPrincipalOnOperationContext = value;
 481317                }
 481318            }
 319        }
 320
 321        internal bool SupportsAuthorizationData
 322        {
 323            get
 324            {
 1988325                return _supportsAuthorizationData;
 326            }
 327            set
 328            {
 427329                lock (ThisLock)
 330                {
 427331                    InvalidateRuntime();
 427332                    _supportsAuthorizationData = value;
 427333                }
 427334            }
 335        }
 336
 661337        internal SynchronizedCollection<IInputSessionShutdown> InputSessionShutdownHandlers { get; }
 338
 339        public bool IgnoreTransactionMessageProperty
 340        {
 0341            get { return _ignoreTransactionMessageProperty; }
 342            set
 343            {
 0344                lock (ThisLock)
 345                {
 0346                    InvalidateRuntime();
 0347                    _ignoreTransactionMessageProperty = value;
 0348                }
 0349            }
 350        }
 351
 352        public IInstanceProvider InstanceProvider
 353        {
 4976354            get { return _instanceProvider; }
 355            set
 356            {
 541357                lock (ThisLock)
 358                {
 541359                    InvalidateRuntime();
 541360                    _instanceProvider = value;
 541361                }
 541362            }
 363        }
 364
 1325365        public SynchronizedCollection<IDispatchMessageInspector> MessageInspectors { get; }
 366
 367        public SynchronizedKeyedCollection<string, DispatchOperation> Operations
 368        {
 22789369            get { return _operations; }
 370        }
 371
 372        public IDispatchOperationSelector OperationSelector
 373        {
 699374            get { return _operationSelector; }
 375            set
 376            {
 38377                lock (ThisLock)
 378                {
 38379                    InvalidateRuntime();
 38380                    _operationSelector = value;
 38381                }
 38382            }
 383        }
 384
 661385        internal SynchronizedCollection<IInstanceContextInitializer> InstanceContextInitializers { get; }
 386
 387        public SynchronizationContext SynchronizationContext
 388        {
 661389            get { return _synchronizationContext; }
 390            set
 391            {
 27392                lock (ThisLock)
 393                {
 27394                    InvalidateRuntime();
 27395                    _synchronizationContext = value;
 27396                }
 27397            }
 398        }
 399
 400        public PrincipalPermissionMode PrincipalPermissionMode
 401        {
 402            get
 403            {
 1295404                return _principalPermissionMode;
 405            }
 406            set
 407            {
 664408                if (!PrincipalPermissionModeHelper.IsDefined(value))
 409                {
 0410                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 411                }
 412
 664413                lock (ThisLock)
 414                {
 664415                    InvalidateRuntime();
 664416                    _principalPermissionMode = value;
 664417                }
 664418            }
 419        }
 420
 421        //public RoleProvider RoleProvider
 422        //{
 423        //    get { return (RoleProvider)this.roleProvider; }
 424        //    set
 425        //    {
 426        //        lock (this.ThisLock)
 427        //        {
 428        //            this.InvalidateRuntime();
 429        //            this.roleProvider = value;
 430        //        }
 431        //    }
 432        //}
 433
 434        //public bool TransactionAutoCompleteOnSessionClose
 435        //{
 436        //    get { return this.transactionAutoCompleteOnSessionClose; }
 437        //    set
 438        //    {
 439        //        lock (this.ThisLock)
 440        //        {
 441        //            this.InvalidateRuntime();
 442        //            this.transactionAutoCompleteOnSessionClose = value;
 443        //        }
 444        //    }
 445        //}
 446
 447        public Type Type
 448        {
 1880449            get { return _type; }
 450            set
 451            {
 641452                lock (ThisLock)
 453                {
 641454                    InvalidateRuntime();
 641455                    _type = value;
 641456                }
 641457            }
 458        }
 459
 460        public DispatchOperation UnhandledDispatchOperation
 461        {
 802462            get { return _unhandled; }
 463            set
 464            {
 70465                if (value == null)
 466                {
 0467                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 468                }
 469
 70470                lock (ThisLock)
 471                {
 70472                    InvalidateRuntime();
 70473                    _unhandled = value;
 70474                }
 70475            }
 476        }
 477
 478        public bool ValidateMustUnderstand
 479        {
 661480            get { return _shared.ValidateMustUnderstand; }
 481            set
 482            {
 641483                lock (ThisLock)
 484                {
 641485                    InvalidateRuntime();
 641486                    _shared.ValidateMustUnderstand = value;
 641487                }
 641488            }
 489        }
 490
 664491        internal bool RequiresAuthentication { get; private set; }
 492
 493        internal bool RequiresAuthorization
 663494            => _isAuthorizationManagerSet || _isExternalPoliciesSet;
 495
 496        internal bool HasMatchAllOperation
 497        {
 498            get
 499            {
 10500                lock (ThisLock)
 501                {
 10502                    return !(_unhandled.Invoker is UnhandledActionInvoker);
 503                }
 10504            }
 505        }
 506
 507        internal bool EnableFaults
 508        {
 509            get
 510            {
 661511                if (IsOnServer)
 512                {
 661513                    ChannelDispatcher channelDispatcher = ChannelDispatcher;
 661514                    return (channelDispatcher != null) && channelDispatcher.EnableFaults;
 515                }
 516                else
 517                {
 0518                    return _shared.EnableFaults;
 519                }
 520            }
 521        }
 522
 523        internal bool IsOnServer
 524        {
 1984525            get { return _shared.IsOnServer; }
 526        }
 527
 528        internal bool ManualAddressing
 529        {
 530            get
 531            {
 662532                if (IsOnServer)
 533                {
 662534                    ChannelDispatcher channelDispatcher = ChannelDispatcher;
 662535                    return (channelDispatcher != null) && channelDispatcher.ManualAddressing;
 536                }
 537                else
 538                {
 0539                    return _shared.ManualAddressing;
 540                }
 541            }
 542        }
 543
 544        internal int MaxCallContextInitializers
 545        {
 546            get
 547            {
 661548                lock (ThisLock)
 549                {
 661550                    int max = 0;
 551
 7348552                    for (int i = 0; i < _operations.Count; i++)
 553                    {
 3013554                        max = Math.Max(max, _operations[i].CallContextInitializers.Count);
 555                    }
 661556                    max = Math.Max(max, _unhandled.CallContextInitializers.Count);
 661557                    return max;
 558                }
 661559            }
 560        }
 561
 562        internal int MaxParameterInspectors
 563        {
 564            get
 565            {
 661566                lock (ThisLock)
 567                {
 661568                    int max = 0;
 569
 7348570                    for (int i = 0; i < _operations.Count; i++)
 571                    {
 3013572                        max = Math.Max(max, _operations[i].ParameterInspectors.Count);
 573                    }
 661574                    max = Math.Max(max, _unhandled.ParameterInspectors.Count);
 661575                    return max;
 576                }
 661577            }
 578        }
 579
 580        // Internal access to CallbackClientRuntime, but this one doesn't create on demand
 2701581        internal ClientRuntime ClientRuntime { get; private set; }
 582
 583        internal object ThisLock
 584        {
 96141585            get { return _shared; }
 586        }
 587
 588        //internal bool IsRoleProviderSet
 589        //{
 590        //    get { return this.roleProvider != null; }
 591        //}
 592
 593        internal DispatchOperationRuntime GetOperation(ref Message message)
 594        {
 2539595            ImmutableDispatchRuntime runtime = GetRuntime();
 2539596            return runtime.GetOperation(ref message);
 597        }
 598
 599        internal ImmutableDispatchRuntime GetRuntime()
 600        {
 3281601            ImmutableDispatchRuntime runtime = _runtime;
 3281602            if (runtime != null)
 603            {
 2617604                return runtime;
 605            }
 606            else
 607            {
 664608                return GetRuntimeCore();
 609            }
 610        }
 611
 612        private ImmutableDispatchRuntime GetRuntimeCore()
 613        {
 664614            lock (ThisLock)
 615            {
 664616                if (_runtime == null)
 617                {
 664618                    _runtime = new ImmutableDispatchRuntime(this);
 619                }
 620
 661621                return _runtime;
 622            }
 661623        }
 624
 111625        internal bool IsAuthorizationInfrastructureRegistered() => _authorizationService != null;
 626
 627        internal void InvalidateRuntime()
 628        {
 41459629            lock (ThisLock)
 630            {
 41459631                _shared.ThrowIfImmutable();
 41459632                _runtime = null;
 41459633            }
 41459634        }
 635
 636        internal void LockDownProperties()
 637        {
 661638            _shared.LockDownProperties();
 661639            if (_concurrencyMode != ConcurrencyMode.Single && _ensureOrderedDispatch)
 640            {
 0641                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SfxDispatchRu
 642            }
 661643        }
 644
 645        internal SynchronizedCollection<T> NewBehaviorCollection<T>()
 646        {
 13242647            return new DispatchBehaviorCollection<T>(this);
 648        }
 649
 650        internal class UnhandledActionInvoker : IOperationInvoker
 651        {
 652            private readonly DispatchRuntime _dispatchRuntime;
 653
 664654            public UnhandledActionInvoker(DispatchRuntime dispatchRuntime)
 655            {
 664656                _dispatchRuntime = dispatchRuntime;
 664657            }
 658
 659            public object[] AllocateInputs()
 660            {
 0661                return new object[1];
 662            }
 663
 664            public ValueTask<(object returnValue, object[] outputs)> InvokeAsync(object instance, object[] inputs)
 665            {
 0666                object[] outputs = EmptyArray<object>.Allocate(0);
 667
 0668                if (!(inputs[0] is Message message))
 669                {
 0670                    return new ValueTask<(object returnValue, object[] outputs)>(((object)null, outputs));
 671                }
 672
 0673                string action = message.Headers.Action;
 674
 675                //if (DiagnosticUtility.ShouldTraceInformation)
 676                //{
 677                //    TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.UnhandledAction,
 678                //        SR.TraceCodeUnhandledAction,
 679                //        new StringTraceRecord("Action", action),
 680                //        this, null, message);
 681                //}
 682
 0683                FaultCode code = FaultCode.CreateSenderFaultCode(AddressingStrings.ActionNotSupported,
 0684                    message.Version.Addressing.Namespace);
 0685                string reasonText = SR.Format(SR.SFxNoEndpointMatchingContract, action);
 0686                FaultReason reason = new FaultReason(reasonText);
 687
 0688                FaultException exception = new FaultException(reason, code);
 0689                ErrorBehavior.ThrowAndCatch(exception);
 690
 0691                ServiceChannel serviceChannel = OperationContext.Current.InternalServiceChannel;
 0692                OperationContext.Current.OperationCompleted +=
 0693                    delegate (object sender, EventArgs e)
 0694                    {
 0695                        ChannelDispatcher channelDispatcher = _dispatchRuntime.ChannelDispatcher;
 0696                        if (!channelDispatcher.HandleError(exception) && serviceChannel.HasSession)
 0697                        {
 0698                            try
 0699                            {
 0700                                var helper = new TimeoutHelper(ChannelHandler.CloseAfterFaultTimeout);
 0701                                serviceChannel.CloseAsync(helper.GetCancellationToken()).GetAwaiter().GetResult();
 0702                            }
 0703                            catch (Exception ex)
 0704                            {
 0705                                if (Fx.IsFatal(ex))
 0706                                {
 0707                                    throw;
 0708                                }
 0709                                channelDispatcher.HandleError(ex);
 0710                            }
 0711                        }
 0712                    };
 713
 0714                if (_dispatchRuntime._shared.EnableFaults)
 715                {
 0716                    MessageFault fault = MessageFault.CreateFault(code, reason, action);
 0717                    return new ValueTask<(object returnValue, object[] outputs)>(
 0718                        (Message.CreateMessage(message.Version, fault, message.Version.Addressing.DefaultFaultAction),
 0719                         outputs));
 720                }
 721                else
 722                {
 0723                    OperationContext.Current.RequestContext.CloseAsync().GetAwaiter().GetResult();
 0724                    OperationContext.Current.RequestContext = null;
 0725                    return new ValueTask<(object returnValue, object[] outputs)>((null, outputs));
 726                }
 727            }
 728
 729
 730
 731            public IAsyncResult InvokeBegin(object instance, object[] inputs, AsyncCallback callback, object state)
 732            {
 0733                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 734            }
 735
 736            public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
 737            {
 0738                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 739            }
 740        }
 741
 742        private class DispatchBehaviorCollection<T> : SynchronizedCollection<T>
 743        {
 744            private readonly DispatchRuntime _outer;
 745
 746            internal DispatchBehaviorCollection(DispatchRuntime outer)
 13242747                : base(outer.ThisLock)
 748            {
 13242749                _outer = outer;
 13242750            }
 751
 752            protected override void ClearItems()
 753            {
 0754                _outer.InvalidateRuntime();
 0755                base.ClearItems();
 0756            }
 757
 758            protected override void InsertItem(int index, T item)
 759            {
 168760                if (item == null)
 761                {
 0762                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(item));
 763                }
 764
 168765                _outer.InvalidateRuntime();
 168766                base.InsertItem(index, item);
 168767            }
 768
 769            protected override void RemoveItem(int index)
 770            {
 0771                _outer.InvalidateRuntime();
 0772                base.RemoveItem(index);
 0773            }
 774
 775            protected override void SetItem(int index, T item)
 776            {
 0777                if (item == null)
 778                {
 0779                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(item));
 780                }
 781
 0782                _outer.InvalidateRuntime();
 0783                base.SetItem(index, item);
 0784            }
 785        }
 786
 787        private class OperationCollection : SynchronizedKeyedCollection<string, DispatchOperation>
 788        {
 789            private readonly DispatchRuntime _outer;
 790
 791            internal OperationCollection(DispatchRuntime outer)
 664792                : base(outer.ThisLock)
 793            {
 664794                _outer = outer;
 664795            }
 796
 797            protected override void ClearItems()
 798            {
 0799                _outer.InvalidateRuntime();
 0800                base.ClearItems();
 0801            }
 802
 803            protected override string GetKeyForItem(DispatchOperation item)
 804            {
 42731805                return item.Name;
 806            }
 807
 808            protected override void InsertItem(int index, DispatchOperation item)
 809            {
 3016810                if (item == null)
 811                {
 0812                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(item));
 813                }
 3016814                if (item.Parent != _outer)
 815                {
 0816                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.SFxMismatchedOperationParent);
 817                }
 818
 3016819                _outer.InvalidateRuntime();
 3016820                base.InsertItem(index, item);
 3016821            }
 822
 823            protected override void RemoveItem(int index)
 824            {
 0825                _outer.InvalidateRuntime();
 0826                base.RemoveItem(index);
 0827            }
 828
 829            protected override void SetItem(int index, DispatchOperation item)
 830            {
 0831                if (item == null)
 832                {
 0833                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(item));
 834                }
 0835                if (item.Parent != _outer)
 836                {
 0837                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.SFxMismatchedOperationParent);
 838                }
 839
 0840                _outer.InvalidateRuntime();
 0841                base.SetItem(index, item);
 0842            }
 843        }
 844
 845        private class CallbackInstanceProvider : IInstanceProvider
 846        {
 847            object IInstanceProvider.GetInstance(InstanceContext instanceContext)
 848            {
 0849                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxCannotActi
 850            }
 851
 852            object IInstanceProvider.GetInstance(InstanceContext instanceContext, Message message)
 853            {
 0854                throw TraceUtility.ThrowHelperError(new InvalidOperationException(SR.SFxCannotActivateCallbackInstace), 
 855            }
 856
 857            void IInstanceProvider.ReleaseInstance(InstanceContext instanceContext, object instance)
 858            {
 0859                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxCannotActi
 860            }
 861        }
 862    }
 863}

Methods/Properties

.ctor(CoreWCF.Dispatcher.EndpointDispatcher)
.ctor(CoreWCF.Dispatcher.ClientRuntime,CoreWCF.Dispatcher.SharedRuntimeState)
.ctor(CoreWCF.Dispatcher.SharedRuntimeState)
InstanceContextProvider()
InstanceContextProvider(CoreWCF.Dispatcher.IInstanceContextProvider)
SingletonInstanceContext()
SingletonInstanceContext(CoreWCF.InstanceContext)
ConcurrencyMode()
ConcurrencyMode(CoreWCF.ConcurrencyMode)
EnsureOrderedDispatch()
EnsureOrderedDispatch(System.Boolean)
ExternalAuthorizationPolicies()
ExternalAuthorizationPolicies(System.Collections.ObjectModel.ReadOnlyCollection`1<CoreWCF.IdentityModel.Policy.IAuthorizationPolicy>)
ServiceAuthenticationManager()
ServiceAuthenticationManager(CoreWCF.ServiceAuthenticationManager)
ServiceAuthorizationManager()
ServiceAuthorizationManager(CoreWCF.ServiceAuthorizationManager)
AuthorizationService()
AuthorizationService(Microsoft.AspNetCore.Authorization.IAuthorizationService)
GetAuthorizationService()
SetAuthorizationService(Microsoft.AspNetCore.Authorization.IAuthorizationService)
AutomaticInputSessionShutdown()
AutomaticInputSessionShutdown(System.Boolean)
ChannelDispatcher()
CallbackClientRuntime()
EndpointDispatcher()
ImpersonateCallerForAllOperations()
ImpersonateCallerForAllOperations(System.Boolean)
ImpersonateOnSerializingReply()
ImpersonateOnSerializingReply(System.Boolean)
RequireClaimsPrincipalOnOperationContext()
RequireClaimsPrincipalOnOperationContext(System.Boolean)
SupportsAuthorizationData()
SupportsAuthorizationData(System.Boolean)
InputSessionShutdownHandlers()
IgnoreTransactionMessageProperty()
IgnoreTransactionMessageProperty(System.Boolean)
InstanceProvider()
InstanceProvider(CoreWCF.Dispatcher.IInstanceProvider)
MessageInspectors()
Operations()
OperationSelector()
OperationSelector(CoreWCF.Dispatcher.IDispatchOperationSelector)
InstanceContextInitializers()
SynchronizationContext()
SynchronizationContext(System.Threading.SynchronizationContext)
PrincipalPermissionMode()
PrincipalPermissionMode(CoreWCF.Description.PrincipalPermissionMode)
Type()
Type(System.Type)
UnhandledDispatchOperation()
UnhandledDispatchOperation(CoreWCF.Dispatcher.DispatchOperation)
ValidateMustUnderstand()
ValidateMustUnderstand(System.Boolean)
RequiresAuthentication()
RequiresAuthorization()
HasMatchAllOperation()
EnableFaults()
IsOnServer()
ManualAddressing()
MaxCallContextInitializers()
MaxParameterInspectors()
ClientRuntime()
ThisLock()
GetOperation(CoreWCF.Channels.Message&)
GetRuntime()
GetRuntimeCore()
IsAuthorizationInfrastructureRegistered()
InvalidateRuntime()
LockDownProperties()
NewBehaviorCollection()
.ctor(CoreWCF.Dispatcher.DispatchRuntime)
AllocateInputs()
InvokeAsync(System.Object,System.Object[])
InvokeBegin(System.Object,System.Object[],System.AsyncCallback,System.Object)
InvokeEnd(System.Object,System.Object[]&,System.IAsyncResult)
.ctor(CoreWCF.Dispatcher.DispatchRuntime)
ClearItems()
InsertItem(System.Int32,T)
RemoveItem(System.Int32)
SetItem(System.Int32,T)
.ctor(CoreWCF.Dispatcher.DispatchRuntime)
ClearItems()
GetKeyForItem(CoreWCF.Dispatcher.DispatchOperation)
InsertItem(System.Int32,CoreWCF.Dispatcher.DispatchOperation)
RemoveItem(System.Int32)
SetItem(System.Int32,CoreWCF.Dispatcher.DispatchOperation)
CoreWCF.Dispatcher.IInstanceProvider.GetInstance(CoreWCF.InstanceContext)
CoreWCF.Dispatcher.IInstanceProvider.GetInstance(CoreWCF.InstanceContext,CoreWCF.Channels.Message)
CoreWCF.Dispatcher.IInstanceProvider.ReleaseInstance(CoreWCF.InstanceContext,System.Object)