public bool NextPathSegment()
                {
                    UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum uriSegmentEnum = this;
                    uriSegmentEnum.segmentStartAt = uriSegmentEnum.segmentStartAt + this.segmentLength;
                    while (this.segmentStartAt < this.segment.Length && this.segment[this.segmentStartAt] == '/')
                    {
                        UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum uriSegmentEnum1 = this;
                        uriSegmentEnum1.segmentStartAt = uriSegmentEnum1.segmentStartAt + 1;
                    }
                    if (this.segmentStartAt >= this.segment.Length)
                    {
                        this.ClearSegment();
                        return(false);
                    }
                    int num = this.segment.IndexOf('/', this.segmentStartAt);

                    if (-1 != num)
                    {
                        this.segmentLength = num - this.segmentStartAt;
                    }
                    else
                    {
                        this.segmentLength = this.segment.Length - this.segmentStartAt;
                    }
                    return(true);
                }
 private void ClearSegment()
 {
     this.type           = UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.None;
     this.segment        = string.Empty;
     this.segmentStartAt = 0;
     this.segmentLength  = 0;
 }
                public bool Next()
                {
                    switch (this.type)
                    {
                    case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Unknown:
                    {
                        this.type = UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Scheme;
                        this.SetSegment(this.uri.Scheme);
                        return(true);
                    }

                    case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Scheme:
                    {
                        this.type = UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Host;
                        string host     = this.uri.Host;
                        string userInfo = this.uri.UserInfo;
                        if (userInfo != null && userInfo.Length > 0)
                        {
                            host = string.Concat(userInfo, '@', host);
                        }
                        this.SetSegment(host);
                        return(true);
                    }

                    case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Host:
                    {
                        this.type = UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Port;
                        int port = this.uri.Port;
                        this.SetSegment(port.ToString(CultureInfo.InvariantCulture));
                        return(true);
                    }

                    case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Port:
                    {
                        this.type = UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Path;
                        string absolutePath = this.uri.AbsolutePath;
                        if (absolutePath.Length == 0)
                        {
                            this.ClearSegment();
                            return(false);
                        }
                        this.segment        = absolutePath;
                        this.segmentStartAt = 0;
                        this.segmentLength  = 0;
                        return(this.NextPathSegment());
                    }

                    case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Path:
                    {
                        return(this.NextPathSegment());
                    }

                    case (UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType)UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.None:
                    {
                        return(false);
                    }
                    }
                    return(false);
                }
 internal UriSegmentEnum(Uri uri)
 {
     this.uri            = uri;
     this.type           = UriPrefixTable <TItem> .UriSegmenter.UriSegmentEnum.UriSegmentType.Unknown;
     this.segment        = null;
     this.segmentStartAt = 0;
     this.segmentLength  = 0;
 }
 internal UriPrefixTable(UriPrefixTable <TItem> objectToClone) : this(objectToClone.includePortInComparison, objectToClone.useWeakReferences)
 {
     if (objectToClone.Count > 0)
     {
         foreach (KeyValuePair <BaseUriWithWildcard, TItem> all in objectToClone.GetAll())
         {
             this.RegisterUri(all.Key.BaseAddress, all.Key.HostNameComparisonMode, all.Value);
         }
     }
 }
        public void UnregisterUri(Uri uri, HostNameComparisonMode hostNameComparisonMode)
        {
            lock (this.ThisLock)
            {
                this.ClearCache();
                string[] path = UriPrefixTable <TItem> .UriSegmenter.ToPath(uri, hostNameComparisonMode, this.includePortInComparison);

                if ((int)path.Length != 0)
                {
                    this.root.RemovePath(path, 0);
                }
                else
                {
                    this.root.RemoveData();
                }
                UriPrefixTable <TItem> uriPrefixTable = this;
                uriPrefixTable.count = uriPrefixTable.count - 1;
            }
        }
 public void RegisterUri(Uri uri, HostNameComparisonMode hostNameComparisonMode, TItem item)
 {
     lock (this.ThisLock)
     {
         this.ClearCache();
         BaseUriWithWildcard          baseUriWithWildcard  = new BaseUriWithWildcard(uri, hostNameComparisonMode);
         SegmentHierarchyNode <TItem> segmentHierarchyNode = this.FindOrCreateNode(baseUriWithWildcard);
         if (segmentHierarchyNode.Data != null)
         {
             ExceptionUtility exceptionUtility      = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility;
             string           duplicateRegistration = Resources.DuplicateRegistration;
             object[]         objArray = new object[] { uri };
             throw exceptionUtility.ThrowHelperError(new InvalidOperationException(Microsoft.ServiceBus.SR.GetString(duplicateRegistration, objArray)));
         }
         segmentHierarchyNode.SetData(item, baseUriWithWildcard);
         UriPrefixTable <TItem> uriPrefixTable = this;
         uriPrefixTable.count = uriPrefixTable.count + 1;
     }
 }