Exemple #1
0
        public bool PathExists(string path)
        {
            string ns = path;

            int lastIndex = 0;
            CliNamespaceKeyedTree topLevel = this.info;

nextPart:
            int next = ns.IndexOf('.', lastIndex);

            if (next != -1)
            {
                string current     = ns.Substring(lastIndex, next - lastIndex);
                uint   currentHash = (uint)current.GetHashCode();
                if (topLevel.ContainsKey(currentHash))
                {
                    topLevel = topLevel[currentHash];
                }
                else
                {
                    return(false);
                }
                lastIndex = next + 1;
                goto nextPart;
            }
            else
            {
                string current     = ns.Substring(lastIndex);
                uint   currentHash = (uint)current.GetHashCode();
                return(topLevel.ContainsKey(currentHash));
            }
        }
Exemple #2
0
        public INamespaceDeclaration this[string path]
        {
            get
            {
                string ns = path;

                int lastIndex = 0;
                CliNamespaceKeyedTree topLevel         = this.info;
                INamespaceDictionary  topNamespaceDict = this;
                StringBuilder         pathBuilder      = new StringBuilder();
                bool first = true;
nextPart:
                int next = ns.IndexOf('.', lastIndex);
                if (first)
                {
                    first = false;
                }
                else
                {
                    pathBuilder.Append('.');
                }
                if (next != -1)
                {
                    string current = ns.Substring(lastIndex, next - lastIndex);
                    pathBuilder.Append(current);
                    uint currentHash = (uint)current.GetHashCode();
                    if (topLevel.ContainsKey(currentHash))
                    {
                        topLevel         = topLevel[currentHash];
                        topNamespaceDict = topNamespaceDict[TypeSystemIdentifiers.GetDeclarationIdentifier(pathBuilder.ToString())].Namespaces;
                    }
                    else
                    {
                        return(null);
                    }
                    lastIndex = next + 1;
                    goto nextPart;
                }
                else
                {
                    string current = ns.Substring(lastIndex);
                    pathBuilder.Append(current);
                    uint currentHash = (uint)current.GetHashCode();
                    if (topLevel.ContainsKey(currentHash))
                    {
                        topLevel = topLevel[currentHash];
                        return(topNamespaceDict[TypeSystemIdentifiers.GetDeclarationIdentifier(pathBuilder.ToString())]);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }