public void RegisterUri(Uri uri, HostNameComparisonMode hostNameComparisonMode, TItem item)
 {
     lock (this.ThisLock)
     {
         this.ClearCache();
         BaseUriWithWildcard          baseUri = new BaseUriWithWildcard(uri, hostNameComparisonMode);
         SegmentHierarchyNode <TItem> node    = this.FindOrCreateNode(baseUri);
         if (node.Data != null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("DuplicateRegistration", new object[] { uri })));
         }
         node.SetData(item, baseUri);
         this.count++;
     }
 }
Пример #2
0
        public void RegisterUri(Uri uri, HostNameComparisonMode hostNameComparisonMode, TItem item)
        {
            Fx.Assert(HostNameComparisonModeHelper.IsDefined(hostNameComparisonMode), "RegisterUri: Invalid HostNameComparisonMode value passed in.");

            lock (ThisLock)
            {
                // Since every newly registered Uri could alter what Prefixes should have matched, we
                // should clear the cache of any existing results and start over
                ClearCache();
                BaseUriWithWildcard          key  = new BaseUriWithWildcard(uri, hostNameComparisonMode);
                SegmentHierarchyNode <TItem> node = FindOrCreateNode(key);
                if (node.Data != null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(
                                                                                                                SR.DuplicateRegistration, uri)));
                }
                node.SetData(item, key);
                count++;
            }
        }