56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
using mapper.attributes;
|
|
using System;
|
|
namespace sharpwawi.models
|
|
{
|
|
[MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ALL)]
|
|
public class AssemblyComponent
|
|
{
|
|
[PrimaryKey]
|
|
public PartAssembly Assembly { get; private set; }
|
|
[PrimaryKey]
|
|
public Part Component { get; private set; }
|
|
|
|
public int Position { get; set; }
|
|
public double Quantity { get; set; }
|
|
|
|
public AssemblyComponent()
|
|
{
|
|
}
|
|
|
|
public AssemblyComponent(PartAssembly assembly,Part component, double quantity)
|
|
{
|
|
this.Assembly = assembly;
|
|
this.Component = component;
|
|
this.Quantity = quantity;
|
|
this.Position = 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return Assembly.GetHashCode() ^ Component.GetHashCode();
|
|
}
|
|
|
|
/**
|
|
* Equals()
|
|
*
|
|
* check if an AssemblyComponent instance describes the same Part as Component of an Assembly
|
|
* Differenting Quantities are ignored!
|
|
*
|
|
**/
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj is AssemblyComponent)
|
|
{
|
|
AssemblyComponent other = (AssemblyComponent)obj;
|
|
return Assembly.Equals(other.Assembly) && Component.Equals(other.Component);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
}
|