Exemplo n.º 1
0
        private CodeTypeReference CorrectNamespace(CodeTypeReference reference, CodeNamespace output, HashSet <string> usings, Dictionary <string, string> nameConflicts)
        {
            var refNs = reference.Namespace();

            if (refNs != null)
            {
                string chosenNs;
                if (refNs != output.Name)
                {
                    if (nameConflicts.TryGetValue(reference.BaseType, out chosenNs) && chosenNs != refNs)
                    {
                        // We are in a namespace conflict and need to fully qualify the reference
                        reference.BaseType = refNs + "." + reference.BaseType;
                    }
                    else
                    {
                        usings.Add(refNs);
                    }
                }
            }
            for (int i = 0; i < reference.TypeArguments.Count; i++)
            {
                reference.TypeArguments[i] = CorrectNamespace(reference.TypeArguments[i], output, usings, nameConflicts);
            }
            return(reference);
        }
Exemplo n.º 2
0
        private void RegisterConflicts(CodeTypeReference reference, Dictionary <string, string> nameDict)
        {
            var refNs = reference.Namespace();

            if (refNs != null)
            {
                RegisterConflict(reference.BaseType, nameDict, refNs);
            }
        }
Exemplo n.º 3
0
        private void RegisterConflicts(CodeTypeReference reference, Dictionary <string, string> nameDict)
        {
            var refNs = reference.Namespace();

            if (refNs != null)
            {
                string chosenClass;
                if (nameDict.TryGetValue(reference.BaseType, out chosenClass))
                {
                    if (refNs != chosenClass)
                    {
                        nameDict[reference.BaseType] = null;
                    }
                }
                else
                {
                    nameDict.Add(reference.BaseType, IsSystemNameConflict(reference.BaseType) ? null : refNs);
                }
            }
        }