sharp-wawi/models/AssemblyComponent.cs

56 lines
1.5 KiB
C#
Raw Normal View History

2018-08-01 23:33:10 +02:00
using mapper.attributes;
using System;
namespace sharpwawi.models
2018-07-30 17:55:15 +02:00
{
2018-08-01 23:33:10 +02:00
[MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ALL)]
2018-07-30 17:55:15 +02:00
public class AssemblyComponent
{
2018-08-01 23:33:10 +02:00
[PrimaryKey]
2018-09-12 21:29:58 +02:00
public PartAssembly Assembly { get; private set; }
2018-08-01 23:33:10 +02:00
[PrimaryKey]
2018-07-30 17:55:15 +02:00
public Part Component { get; private set; }
2018-08-01 23:33:10 +02:00
public int Position { get; set; }
2018-07-30 17:55:15 +02:00
public double Quantity { get; set; }
public AssemblyComponent()
{
}
2018-09-12 21:29:58 +02:00
public AssemblyComponent(PartAssembly assembly,Part component, double quantity)
2018-07-30 17:55:15 +02:00
{
this.Assembly = assembly;
this.Component = component;
this.Quantity = quantity;
2018-08-01 23:33:10 +02:00
this.Position = 0;
2018-07-30 17:55:15 +02:00
}
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;
}
}
}