internal void AddNamespaceDefinition(AssemblyNamespaceDefinition definition)
 {
     _namespaces.Add(definition);
 }
 internal AssemblyTypeDefinition(AssemblyNamespaceDefinition namespaceDef, TypeDefinition definition)
 {
     _namespaceDefinition = namespaceDef;
     _definition = definition;
 }
 internal AssemblyNamespaceDefinition(NetAssembly assembly, AssemblyNamespaceDefinition parent, string name)
 {
     _assembly = assembly;
     _parent = parent;
     _name = name;
 }
Esempio n. 4
0
        private AssemblyNamespaceDefinition GetNamespaceDefinition(string @namespace)
        {
            var existingDefinition = _namespaceDefinitions.FirstOrDefault(x => x.FullName == @namespace);
            if (existingDefinition != null)
                return existingDefinition;

            int dotIndex = @namespace.LastIndexOf('.');

            if (dotIndex == -1)
            {
                existingDefinition = new AssemblyNamespaceDefinition(this, null, @namespace);
                _namespaceDefinitions.Add(existingDefinition);
                return existingDefinition;
            }

            var parentDefinition = GetNamespaceDefinition(@namespace.Remove(dotIndex));

            existingDefinition = new AssemblyNamespaceDefinition(this, parentDefinition, @namespace.Substring(dotIndex + 1, @namespace.Length - dotIndex - 1));
            parentDefinition.AddNamespaceDefinition(existingDefinition);
            _namespaceDefinitions.Add(existingDefinition);

            return existingDefinition;
        }