public V4IPRange(CustomerIPAddress address) { var toIpAllNull = address.IpAddressToNode1 == null && address.IpAddressToNode2 == null && address.IpAddressToNode3 == null && address.IpAddressToNode4 == null; var toIpAllNotNull = address.IpAddressToNode1 != null && address.IpAddressToNode2 != null && address.IpAddressToNode3 != null && address.IpAddressToNode4 != null; if (!toIpAllNull && !toIpAllNotNull) { throw new ArgumentException("The to IP address must be either completely null or completely defined"); } var start = new V4IpAddress(address.IpAddressFromNode1, address.IpAddressFromNode2, address.IpAddressFromNode3, address.IpAddressFromNode4); var end = toIpAllNotNull ? new V4IpAddress(address.IpAddressToNode1.Value, address.IpAddressToNode2.Value, address.IpAddressToNode3.Value, address.IpAddressToNode4.Value) : new V4IpAddress(address.IpAddressFromNode1, address.IpAddressFromNode2, address.IpAddressFromNode3, address.IpAddressFromNode4); if (start > end) { throw new ArgumentException("End IP address cannot be less than start address."); } Start = start; End = end; }
public V4IPRange(V4IpAddress start, V4IpAddress end) { if (start > end) { throw new ArgumentException("End IP address cannot be less than start address."); } Start = start; End = end; }