Ejemplo n.º 1
0
        public void AddSynthesizedDefinition(INamespaceSymbolInternal container, INamespaceOrTypeSymbolInternal typeOrNamespace)
        {
            Debug.Assert(typeOrNamespace != null);
            if (_lazySynthesizedNamespaceMembers == null)
            {
                Interlocked.CompareExchange(ref _lazySynthesizedNamespaceMembers, new ConcurrentDictionary <INamespaceSymbolInternal, ConcurrentQueue <INamespaceOrTypeSymbolInternal> >(), null);
            }

            _lazySynthesizedNamespaceMembers.GetOrAdd(container, _ => new ConcurrentQueue <INamespaceOrTypeSymbolInternal>()).Enqueue(typeOrNamespace);
        }
Ejemplo n.º 2
0
            static bool namespaceMatch(
                INamespaceSymbolInternal container,
                string namespaceName,
                StringComparison options
                )
            {
                int  index     = namespaceName.Length;
                bool expectDot = false;

                while (true)
                {
                    if (container.IsGlobalNamespace)
                    {
                        return(index == 0);
                    }

                    if (expectDot)
                    {
                        index--;

                        if (index < 0 || namespaceName[index] != '.')
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        expectDot = true;
                    }

                    string name       = container.Name;
                    int    nameLength = name.Length;
                    index -= nameLength;
                    if (
                        index < 0 ||
                        string.Compare(namespaceName, index, name, 0, nameLength, options) != 0
                        )
                    {
                        return(false);
                    }

                    container = container.ContainingNamespace;

                    if (container is null)
                    {
                        return(false);
                    }
                }
            }