Пример #1
0
        public ICodeEntity GetEntity(ICodeEntity entity)
        {
            if (entities.ContainsKey(entity.EntityFullName))
            {
                return(entities[entity.EntityFullName]);
            }

            entities.Add(entity.EntityFullName, entity);
            entity.UniqueId = entitiesUniqueIdCounter++;

            return(entity);
        }
Пример #2
0
 /// <summary>
 /// 현재 개체가 동일한 형식의 다른 개체와 같은지 여부를 나타냅니다.
 /// </summary>
 /// <returns>
 /// 현재 개체가 <paramref name="other"/> 매개 변수와 같으면 true이고, 그렇지 않으면 false입니다.
 /// </returns>
 /// <param name="other">이 개체와 비교할 개체입니다.</param>
 public bool Equals(ICodeEntity other)
 {
     return((other != null) && GetHashCode().Equals(other.GetHashCode()));
 }
Пример #3
0
 public void AddAssociation(ICodeEntity association)
 {
     associations.Add(association);
 }
        private ICodeEntity AnalyzeType(Type type, CodeAnalysisGraph graph)
        {
            if (false == ShouldBeIncluded(type))
            {
                return(null);
            }

            if (type.IsClass)
            {
                ClassEntity analyzedClass = new ClassEntity(type.Name, type.FullName, type.IsAbstract);
                analyzedClass = (ClassEntity)graph.GetEntity(analyzedClass);

                // skip already analyzed entities
                if (analyzedClass.AnalysisState != CodeEntityAnalysisState.NotAnalyzed)
                {
                    return(analyzedClass);
                }

                analyzedClass.AnalysisState = CodeEntityAnalysisState.InAnalysis;

                // find direct ancestor
                if (type.BaseType != null)
                {
                    ICodeEntity ancestor = AnalyzeType(type.BaseType, graph);

                    if (ancestor != null)
                    {
                        analyzedClass.AddAncestor(ancestor);
                    }
                }

                foreach (Type inheritedInterface in type.GetInterfaces())
                {
                    ICodeEntity ancestor = AnalyzeType(inheritedInterface, graph);

                    if (ancestor != null)
                    {
                        analyzedClass.AddAncestor(ancestor);
                    }
                }

                foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
                {
                    ICodeEntity association = AnalyzeType(field.FieldType, graph);
                    if (association != null)
                    {
                        analyzedClass.AddAssociation(association);
                    }
                }

                analyzedClass.AnalysisState = CodeEntityAnalysisState.Analyzed;

                return(analyzedClass);
            }
            else if (type.IsInterface)
            {
                InterfaceEntity analyzedInterface = new InterfaceEntity(type.Name, type.FullName);
                analyzedInterface = (InterfaceEntity)graph.GetEntity(analyzedInterface);

                // skip already analyzed entities
                if (analyzedInterface.AnalysisState != CodeEntityAnalysisState.NotAnalyzed)
                {
                    return(analyzedInterface);
                }

                analyzedInterface.AnalysisState = CodeEntityAnalysisState.InAnalysis;

                foreach (Type inheritedInterface in type.GetInterfaces())
                {
                    ICodeEntity ancestor = AnalyzeType(inheritedInterface, graph);

                    if (ancestor != null)
                    {
                        analyzedInterface.AddAncestor(ancestor);
                    }
                }

                analyzedInterface.AnalysisState = CodeEntityAnalysisState.Analyzed;

                return(analyzedInterface);
            }

            return(null);
        }
Пример #5
0
 public void AddAncestor(ICodeEntity ancestor)
 {
     ancestors.Add(ancestor);
 }