// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Collections.Generic; namespace ICSharpCode.CodeCoverage { public class CodeCoverageProperty { string name = String.Empty; CodeCoverageMethod getter; CodeCoverageMethod setter; public CodeCoverageProperty() { } public CodeCoverageProperty(CodeCoverageMethod method) { AddMethod(method); } public List GetMethods() { List methods = new List(); if (getter != null) { methods.Add(getter); } if (setter != null) { methods.Add(setter); } return methods; } /// /// Gets the property name. /// public string Name { get { return name; } } public CodeCoverageMethod Getter { get { return getter; } } public CodeCoverageMethod Setter { get { return setter; } } /// /// Adds a getter or setter to the property. /// public void AddMethod(CodeCoverageMethod method) { name = GetPropertyName(method); if (method.IsGetter) { getter = method; } else { setter = method; } } /// /// Strips the get_ or set_ part from a method name and returns the property name. /// public static string GetPropertyName(CodeCoverageMethod method) { if (method.IsProperty) { return method.Name.Substring(4); } return String.Empty; } } }