C# 클래스 Framework.Core.DomainModel.BaseObject

Provides a standard base class for facilitating comparison of objects.
For a discussion of the implementation of Equals/GetHashCode, see http://devlicio.us/blogs/billy_mccafferty/archive/2007/04/25/using-equals-gethashcode-effectively.aspx and http://groups.google.com/group/sharp-architecture/browse_thread/thread/f76d1678e68e3ece?hl=en for an in depth and conclusive resolution.
파일 보기 프로젝트 열기: coreframework/Core-Framework 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
HashMultiplier int

공개 메소드들

메소드 설명
Equals ( Object obj ) : bool

Determines whether the specified System.Object is equal to this instance.

GetHashCode ( ) : int

Returns a hash code for this instance.

This is used to provide the hashcode identifier of an object using the signature properties of the object; although it's necessary for NHibernate's use, this can also be useful for business logic purposes and has been included in this base class, accordingly. Since it is recommended that GetHashCode change infrequently, if at all, in an object's lifetime, it's important that properties are carefully selected which truly represent the signature of an object.

GetSignatureProperties ( ) : IEnumerable

Gets the signature properties.

Static dictionary used to reduce performance. So properties will be retrieved only once per class for each thread after application start.

HasSameObjectSignatureAs ( BaseObject compareTo ) : bool

You may override this method to provide your own comparison routine.

보호된 메소드들

메소드 설명
GetInnerType ( ) : Type

When NHibernate proxies objects, it masks the type of the actual entity object. This wrapper burrows into the proxied object to get its actual type. Although this assumes NHibernate is being used, it doesn't require any NHibernate related dependencies and has no bad side effects if NHibernate isn't being used.

Related discussion is at http://groups.google.com/group/sharp-architecture/browse_thread/thread/ddd05f9baede023a .

GetTypeSpecificSignatureProperties ( ) : IEnumerable

Enforces the template method pattern to have child objects determine which specific properties should and should not be included in the object signature comparison.

BaseObject already takes care of performance caching, so this method shouldn't worry about caching, just return set of properties.

메소드 상세

Equals() 공개 메소드

Determines whether the specified System.Object is equal to this instance.
public Equals ( Object obj ) : bool
obj Object The to compare with this instance.
리턴 bool

GetHashCode() 공개 메소드

Returns a hash code for this instance.
This is used to provide the hashcode identifier of an object using the signature properties of the object; although it's necessary for NHibernate's use, this can also be useful for business logic purposes and has been included in this base class, accordingly. Since it is recommended that GetHashCode change infrequently, if at all, in an object's lifetime, it's important that properties are carefully selected which truly represent the signature of an object.
public GetHashCode ( ) : int
리턴 int

GetInnerType() 보호된 메소드

When NHibernate proxies objects, it masks the type of the actual entity object. This wrapper burrows into the proxied object to get its actual type. Although this assumes NHibernate is being used, it doesn't require any NHibernate related dependencies and has no bad side effects if NHibernate isn't being used.
Related discussion is at http://groups.google.com/group/sharp-architecture/browse_thread/thread/ddd05f9baede023a .
protected GetInnerType ( ) : Type
리턴 System.Type

GetSignatureProperties() 공개 메소드

Gets the signature properties.

Static dictionary used to reduce performance. So properties will be retrieved only once per class for each thread after application start.
public GetSignatureProperties ( ) : IEnumerable
리턴 IEnumerable

GetTypeSpecificSignatureProperties() 보호된 추상적인 메소드

Enforces the template method pattern to have child objects determine which specific properties should and should not be included in the object signature comparison.
BaseObject already takes care of performance caching, so this method shouldn't worry about caching, just return set of properties.
protected abstract GetTypeSpecificSignatureProperties ( ) : IEnumerable
리턴 IEnumerable

HasSameObjectSignatureAs() 공개 메소드

You may override this method to provide your own comparison routine.
public HasSameObjectSignatureAs ( BaseObject compareTo ) : bool
compareTo BaseObject The to compare with this instance.
리턴 bool

프로퍼티 상세

HashMultiplier 공개적으로 정적으로 프로퍼티

To help ensure hashcode uniqueness, a carefully selected random number multiplier is used within the calculation. Goodrich and Tamassia's Data Structures and Algorithms in Java asserts that 31, 33, 37, 39 and 41 will produce the fewest number of collissions.
See http://computinglife.wordpress.com/2008/11/20/why-do-hash-functions-use-prime-numbers/ for more information.
public static int HashMultiplier
리턴 int