public void AddMapping(CBusProtcol.ApplicationTypes ApplicationType, byte Address) { var findByAddress = AddressMap.Where(m => m.Address == Address); var mappingAlreadyAdded = false; foreach (var mapping in findByAddress) { if (mapping.ApplicationType != ApplicationType) { throw new ApplicationException("Duplicate Addresses for Different Application Types Detected"); } if (mapping.Address == Address && mapping.ApplicationType == ApplicationType) { mappingAlreadyAdded = true; } } if (!mappingAlreadyAdded) { AddressMap.Add(new Mapping(ApplicationType, Address)); } }
bool TryGetApplicationAddress(CBusProtcol.ApplicationTypes ApplicationType, out byte Address) { var mapping = AddressMap.SingleOrDefault(x => x.ApplicationType == ApplicationType); if (mapping != null) { Address = mapping.Address; return(true); } else { Address = 0; return(false); } }
public Mapping(CBusProtcol.ApplicationTypes ApplicationType, byte Address) { this.ApplicationType = ApplicationType; this.Address = Address; }