From 12ee34ca8f3f86aebe95df96119617b5c0fa4f35 Mon Sep 17 00:00:00 2001 From: chadsowald Date: Thu, 18 Sep 2014 12:51:30 -0700 Subject: [PATCH 1/2] Add equality members to fix key-ref merging. --- .../Factory/Config/RuntimeObjectReference.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/RuntimeObjectReference.cs b/src/Spring/Spring.Core/Objects/Factory/Config/RuntimeObjectReference.cs index 5901e064..9a061bb4 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/RuntimeObjectReference.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/RuntimeObjectReference.cs @@ -1,7 +1,7 @@ #region License /* - * Copyright © 2002-2011 the original author or authors. + * Copyright © 2002-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,5 +126,28 @@ namespace Spring.Objects.Factory.Config private bool _isToParent; #endregion + + #region Equality Members + protected bool Equals(RuntimeObjectReference other) + { + return string.Equals(_objectName, other._objectName) && _isToParent.Equals(other._isToParent); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((RuntimeObjectReference)obj); + } + + public override int GetHashCode() + { + unchecked + { + return (_objectName.GetHashCode() * 397) ^ _isToParent.GetHashCode(); + } + } + #endregion } -} \ No newline at end of file +} From 1acf52e5b9e50d1d71f5adc2226c6449f6bffda1 Mon Sep 17 00:00:00 2001 From: chadsowald Date: Thu, 18 Sep 2014 12:58:49 -0700 Subject: [PATCH 2/2] Add comments to equality members. --- .../Factory/Config/RuntimeObjectReference.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Spring/Spring.Core/Objects/Factory/Config/RuntimeObjectReference.cs b/src/Spring/Spring.Core/Objects/Factory/Config/RuntimeObjectReference.cs index 9a061bb4..c2b686f1 100644 --- a/src/Spring/Spring.Core/Objects/Factory/Config/RuntimeObjectReference.cs +++ b/src/Spring/Spring.Core/Objects/Factory/Config/RuntimeObjectReference.cs @@ -128,11 +128,20 @@ namespace Spring.Objects.Factory.Config #endregion #region Equality Members + + /// + /// Determines whether the specified RuntimeObjectReference is equal to the current RuntimeObjectReference. + /// + /// true if the specified RuntimeObjectReference is equal to the current RuntimeObjectReference; otherwise, false. protected bool Equals(RuntimeObjectReference other) { return string.Equals(_objectName, other._objectName) && _isToParent.Equals(other._isToParent); } + /// + /// Determines whether the specified System.Object is equal to the current RuntimeObjectReference. + /// + /// true if the specified RuntimeObjectReference is equal to the current RuntimeObjectReference; otherwise, false. public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; @@ -140,7 +149,11 @@ namespace Spring.Objects.Factory.Config if (obj.GetType() != this.GetType()) return false; return Equals((RuntimeObjectReference)obj); } - + + /// + /// Serves as a hash function for RuntimeObjectReference. + /// + /// A hash code for the currentRuntimeObjectReference. public override int GetHashCode() { unchecked @@ -148,6 +161,7 @@ namespace Spring.Objects.Factory.Config return (_objectName.GetHashCode() * 397) ^ _isToParent.GetHashCode(); } } + #endregion } }