using System; using System.Collections.Generic; using System.Linq; using System.Text; using QuickGraph; namespace ICSharpCode.CodeQualityAnalysis { public class Method : INode { /// /// Parameters which are used by method /// public ISet Parameters { get; set; } /// /// Types which are used in body of method /// public ISet TypeUses { get; set; } /// /// Methods which are called in body of method /// public ISet MethodUses { get; set; } /// /// Fields which are accesed in body of method /// public ISet FieldUses { get; set; } /// /// A name of method /// public string Name { get; set; } /// /// A return type of method /// public Type ReturnType { get; set; } /// /// Type which owns this method /// public Type Owner { get; set; } /// /// Whether the method is constructor or not /// public bool IsConstructor { get; set; } /// /// Whether the method is public /// public bool IsPublic { get; set; } /// /// Whether the method is private /// public bool IsPrivate { get; set; } /// /// Whether the method is protected /// public bool IsProtected { get; set; } /// /// Whether the method is static /// public bool IsStatic { get; set; } /// /// Whether the method is sealed /// public bool IsSealed { get; set; } /// /// Whether the method is abstract /// public bool IsAbstract { get; set; } /// /// Whether the method is setter /// public bool IsSetter { get; set; } /// /// Whether the method is getter /// public bool IsGetter { get; set; } /// /// Whether the method is virtual /// public bool IsVirtual { get; set; } /// /// If the return type is generic instance so all types used in generic are presented in this set. /// public ISet GenericReturnTypes { get; set; } /// /// Whether the return type is generic instance /// public bool IsReturnTypeGenericInstance { get; set; } public Method() { Parameters = new HashSet(); TypeUses = new HashSet(); MethodUses = new HashSet(); FieldUses = new HashSet(); GenericReturnTypes = new HashSet(); ReturnType = null; Owner = null; IsReturnTypeGenericInstance = false; Dependency = null; } public Relationship GetRelationship(INode node) { Relationship relationship = new Relationship(); return relationship; } public override string ToString() { return Name; } public IDependency Dependency { get; set; } public string GetInfo() { var builder = new StringBuilder(); builder.AppendLine("Method Summary"); builder.Append(Environment.NewLine); builder.AppendLine(String.Format("Name: {0}", Name)); builder.AppendLine(String.Format("Parameters: {0}", Parameters.Count)); // more to come builder.Append(Environment.NewLine); if (IsAbstract) builder.AppendLine("IsAbstract"); if (IsConstructor) builder.AppendLine("IsConstructor"); if (IsGetter) builder.AppendLine("IsGetter"); if (IsSetter) builder.AppendLine("IsSetter"); if (IsPrivate) builder.AppendLine("IsPrivate"); if (IsProtected) builder.AppendLine("IsProtected"); if (IsPublic) builder.AppendLine("IsPublic"); if (IsSealed) builder.AppendLine("IsSealed"); if (IsStatic) builder.AppendLine("IsStatic"); if (IsVirtual) builder.AppendLine("IsVirtual"); return builder.ToString(); } } public class MethodParameter { /// /// The type of the parameter /// public Type ParameterType { get; set; } /// /// Whether the parameter is generic instance /// public bool IsGenericInstance { get; set; } /// /// Whether the parameter is in /// public bool IsIn { get; set; } /// /// Whether the parameter is out /// public bool IsOut { get; set; } /// /// Whether the parameter is optional /// public bool IsOptional { get; set; } /// /// If the parameter is generic instance so all types used in generic are presented in this set. /// public ISet GenericTypes { get; set; } public MethodParameter() { GenericTypes = new HashSet(); IsGenericInstance = false; } } }