Beispiel #1
0
        /// <inheritdoc />
        public IEnumerable <Component> FindComponents()
        {
            List <TypeDefinition> types = _typeRepository.GetAllTypes().ToList();

            foreach (TypeDefinition type in types)
            {
                if (!type.HasCustomAttributes)
                {
                    continue;
                }

                ComponentAttribute componentAttribute =
                    type.ResolvableAttributes <ComponentAttribute>().SingleOrDefault();
                if (componentAttribute != null)
                {
                    Component component = ComponentFinder.Container.AddComponent(
                        type.Name,
                        type.GetAssemblyQualifiedName(),
                        componentAttribute.Description,
                        componentAttribute.Technology
                        );
                    _componentsFound.Add(component);
                }
            }

            // Look for code elements after finding all the components
            foreach (TypeDefinition type in types)
            {
                CodeElementAttribute codeElementAttribute = type.ResolvableAttributes <CodeElementAttribute>().SingleOrDefault();
                if (codeElementAttribute != null)
                {
                    Component component =
                        ComponentFinder.Container.GetComponentOfType(codeElementAttribute.ComponentName)
                        ?? ComponentFinder.Container.GetComponentWithName(codeElementAttribute.ComponentName);
                    if (component != null)
                    {
                        CodeElement codeElement = component.AddSupportingType(type.GetAssemblyQualifiedName());
                        codeElement.Description = codeElementAttribute.Description;
                    }
                    else
                    {
                        Console.WriteLine("Could not find component " + codeElementAttribute.ComponentName + " for type " + type.FullName);
                    }
                }
            }

            return(_componentsFound);
        }
Beispiel #2
0
        /// <inheritdoc />
        public IEnumerable <Component> FindComponents()
        {
            foreach (TypeDefinition type in _typeRepository.GetAllTypes())
            {
                foreach (ITypeMatcher typeMatcher in this._typeMatchers)
                {
                    if (typeMatcher.Matches(type))
                    {
                        Component component = ComponentFinder.Container.AddComponent(
                            type.Name,
                            type.GetAssemblyQualifiedName(),
                            typeMatcher.GetDescription(),
                            typeMatcher.GetTechnology());
                        _componentsFound.Add(component);
                    }
                }
            }

            return(_componentsFound);
        }
Beispiel #3
0
 public List <AvatarType> GetTypes()
 {
     return(_typeRepository.GetAllTypes());
 }