public bool Equals(MaterialShadingModelCollection node) { if (node == null || ReferenceEquals(node, this)) { return(true); } if (Count != node.Count) { return(false); } if (Count == 0 || node.Count == 0) { return(true); } foreach (var shadingModelKeyPair in this) { KeyValuePair <IMaterialShadingModelFeature, ShaderSource> shadingModelAgainst; if (!node.TryGetValue(shadingModelKeyPair.Key, out shadingModelAgainst)) { return(false); } if (!shadingModelKeyPair.Value.Key.Equals(shadingModelAgainst.Key)) { return(false); } } return(true); }
/// <summary> /// Compares the shading models of this instance against the specified instance. /// </summary> /// <param name="node">The shading model</param> /// <returns><c>true</c> if shading models are equvalent; <c>false</c> otherwise</returns> public bool Equals(MaterialShadingModelCollection node) { // Methods that allows to deeply compare shading models if (node == null || ReferenceEquals(node, this)) { return(true); } if (Count != node.Count) { return(false); } if (Count == 0 || node.Count == 0) { return(true); } // Because we expect the same number of shading models, we can perform the whole check in a single pass foreach (var shadingModelKeyPair in this) { KeyValuePair <IMaterialShadingModelFeature, ShaderSource> shadingModelAgainst; if (!node.TryGetValue(shadingModelKeyPair.Key, out shadingModelAgainst)) { return(false); } // Note: this method is going to compare deeply the shading models (all implem of IMaterialShadingModelFeature) // and calling their respective Equals method implemented. if (!shadingModelKeyPair.Value.Key.Equals(shadingModelAgainst.Key)) { return(false); } } return(true); }