using System; using System.Collections.Generic; using mapper.attributes; using appsrv.attributes; namespace sharpwawi.models { [MappingConstraint(FieldMappingConstraint = MappingConstraints.ANNOTATEDONLY,PropertyMappingConstraint = MappingConstraints.ANNOTATEDONLY)] public class Part : Entity { public ISet Assemblies { get; private set; } = new HashSet(); [Mapped] public Assembly CurrentAssembly { get; set; } [Mapped] public Part ReplacedBy; public Part() { } public Part(String key,String name) :base(key,name) { } public int HighestAssemblyRevision { get { int highest = 0; foreach (Assembly assembly in Assemblies) if (assembly.Revision > highest) highest = assembly.Revision; return highest; } } [PublishedMember] public int Priority => 1; [PublishedMember] public double Rank => 2.345; public Assembly CreateAssembly(){ Assembly assembly = new Assembly(this); Assemblies.Add(assembly); return assembly; } public override string ToString() { return String.Format("[{0}] {1}",Key,Name); } } }