내부 패턴을 생성하여 계약 패턴을 구성합니다. 개발자는이를 사용하는 갈 때같음 및 참조 동일 않음 숨기기
using System;
using System.Runtime.Serialization;
namespace DCS2000.Common35.Core
{
public class Assertion
{
public static void Ensure(bool test)
{
if (!test)
{
throw new PreconditionException("Precondition test failed");
}
}
public static void Ensure(object obj)
{
if (obj == null)
{
throw new PreconditionException("Precondition null object failed");
}
}
public static void Require(bool test)
{
if (!test)
{
throw new PostconditionException("Postcondition test failed");
}
}
public static void Require(object obj)
{
if (obj == null)
{
throw new PostconditionException("Postcondition null object failed");
}
}
}
}
그들은 인텔리에 옵션으로이 표시됩니다
- 는
- 이는
입니다 필요
참고 : 이미 이것을 시도했다, 그러나 그것은 나를 위해 작동하지 않았다
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj)
{
return base.Equals(obj);
}
이것은 아름답게 작동합니다! 고맙습니다. 유창한 인터페이스를 사용하는 경우 가장 일반적으로 사용되는 객체에서 사용하지 않는 메소드를 찾는 것이 매우 유용하다는 것을 알게되었습니다. – smdrager