Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure_Engine: Adding comparer checking numbers for ICase objects #1790

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2020, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/


using BH.oM.Structure.Loads;
using System.Collections.Generic;
using System;

namespace BH.Engine.Structure
{
public class CaseNumberComaprer : IEqualityComparer<ICase>
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

public bool Equals(ICase case1, ICase case2)
{
//Check whether the compared objects reference the same data.
if (Object.ReferenceEquals(case1, case2))
return true;

//Check whether any of the compared objects is null.
if (Object.ReferenceEquals(case1, null) || Object.ReferenceEquals(case2, null))
return false;

return case1.Number == case2.Number;
}

/***************************************************/

public int GetHashCode(ICase obj)
{
//Check whether the object is null
if (Object.ReferenceEquals(obj, null)) return 0;

return obj.Number.GetHashCode();
}

/***************************************************/

}
}

1 change: 1 addition & 0 deletions Structure_Engine/Structure_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
<Compile Include="Modify\AddReinforcement.cs" />
<Compile Include="Modify\SetMaterial.cs" />
<Compile Include="Modify\SetStructuralFragment.cs" />
<Compile Include="Objects\EqualityComparers\CaseNumberComaprer.cs" />
<Compile Include="Objects\EqualityComparers\Constraint4DOFComparer.cs" />
<Compile Include="Objects\EqualityComparers\Constraint6DOFComparer.cs" />
<Compile Include="Objects\EqualityComparers\NameOrDescriptionComparer.cs" />
Expand Down