本文整理汇总了C#中Material.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Material.GetHashCode方法的具体用法?C# Material.GetHashCode怎么用?C# Material.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Material
的用法示例。
在下文中一共展示了Material.GetHashCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMaterial
/// <summary>
/// Adds the material.
/// </summary>
/// <param name="material">The material.</param>
/// <returns>The ID of material.</returns>
public int AddMaterial(Material material)
{
foreach (var currentMaterial in _materials
.Select((currentMaterial, index) => new { Material = currentMaterial, Index = index })
.Where(currentMaterial => currentMaterial.Material.GetHashCode() == material.GetHashCode() && currentMaterial.Material == material))
{
return currentMaterial.Index;
}
_materials.Add(material);
return _materials.Count - 1;
}
示例2: Material_GetHashCode_returns_same_hash_for_same_object
public void Material_GetHashCode_returns_same_hash_for_same_object()
{
var m1 = new Material();
var m2 = m1;
var hash1 = m1.GetHashCode();
var hash2 = m2.GetHashCode();
Assert.AreEqual(hash1, hash2);
}
示例3: Material_GetHashCode_returns_different_hashes_for_different_objects
public void Material_GetHashCode_returns_different_hashes_for_different_objects()
{
var m1 = new Material() {
Colour = System.Drawing.Color.Green,
Reflectance = 0.3f,
SpecularPower = 50,
SpecularTerm = 1.2f
};
var m2 = new Material() {
Colour = System.Drawing.Color.Teal,
Reflectance = 0.5f,
SpecularPower = 80,
SpecularTerm = 0.8f
};
var hash1 = m1.GetHashCode();
var hash2 = m2.GetHashCode();
Assert.AreNotEqual(hash1, hash2);
}
示例4: Material_GetHashCode_returns_same_hash_for_equivalent_objects
public void Material_GetHashCode_returns_same_hash_for_equivalent_objects()
{
var m1 = new Material() {
Colour = System.Drawing.Color.Green,
Reflectance = 0.3f,
SpecularPower = 50,
SpecularTerm = 1.2f
};
var m2 = new Material() {
Colour = System.Drawing.Color.Green,
Reflectance = 0.3f,
SpecularPower = 50,
SpecularTerm = 1.2f
};
var hash1 = m1.GetHashCode();
var hash2 = m2.GetHashCode();
Assert.AreEqual(hash1, hash2);
}
示例5: Material_GetHashCode_returns
public void Material_GetHashCode_returns()
{
Material m = new Material();
m.GetHashCode();
}