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

BHoM_Engine: add Query.Hash() extension method #2090

Merged
merged 10 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion BHoM_Engine/BHoM_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Compute\Hash.cs" />
<Compile Include="Query\Hash.cs" />
<Compile Include="Create\BHoMGroup.cs" />
<Compile Include="Create\IObject\RandomObject.cs" />
<Compile Include="Create\CustomObject.cs" />
Expand Down
17 changes: 13 additions & 4 deletions BHoM_Engine/Compute/Hash.cs → BHoM_Engine/Query/Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@

namespace BH.Engine.Base
{
public static partial class Compute
public static partial class Query
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/
/***************************************************/

[Description("Computes a Hash code for the iObject. The hash uniquely identifies the iObject based on its properties and their values.")]
alelom marked this conversation as resolved.
Show resolved Hide resolved
[Input("iObj", "iObject the hash code should be calculated for.")]
public static string Hash(this IObject iObj)
{
return Hash(iObj, null);
}

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

[Description("Computes a Hash code for the object which depends solely on its properties.")]
[Input("obj", "Objects the hash code should be calculated for.")]
[Description("Computes a Hash code for the iObject. The hash uniquely identifies the iObject based on its properties and their values.")]
alelom marked this conversation as resolved.
Show resolved Hide resolved
[Input("iObj", "iObject the hash code should be calculated for.")]
[Input("propertyNameExceptions", "(Optional) e.g. `Fragments`. If you want to exclude a property that many objects have.")]
[Input("propertyFullNameExceptions", "(Optional) e.g. `BH.oM.Structure.Elements.Bar.Fragments`. If you want to exclude a specific property of an object.")]
[Input("namespaceExceptions", "(Optional) e.g. `BH.oM.Structure`. Any corresponding namespace is ignored.")]
Expand Down
4 changes: 2 additions & 2 deletions Diffing_Engine/Compute/Hash/DiffingHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public static string DiffingHash(this object obj, DiffConfig diffConfig = null)
{
bhomobj = BH.Engine.Base.Query.DeepClone(obj) as IBHoMObject;
bhomobj.Fragments.Remove(typeof(HashFragment));
return Base.Compute.Hash(bhomobj, diffConfig.PropertiesToIgnore);
return Base.Query.Hash(bhomobj, diffConfig.PropertiesToIgnore);
}

return Base.Compute.Hash(bhomobj, diffConfig.PropertiesToIgnore); // Compute.SHA256Hash(obj, diffConfig.PropertiesToIgnore);
return Base.Query.Hash(bhomobj, diffConfig.PropertiesToIgnore); // Compute.SHA256Hash(obj, diffConfig.PropertiesToIgnore);
}
}
}
Expand Down