public AddressEditViewModel(int id) : this() { AddressRecord = new AddressRecord() { Id = id }; }
public MemMapResult(AddressRecord record) { _virtualAddress = "0x" + record.VirtualAddress.ToString("X08").ToLower(); _physicalAddress = "0x" + record.PhysicalAddress.ToString("X08").ToLower(); _blockSize = "0x" + record.Size.ToString("X").ToLower() + " (" + record.Size.ToString() + ")"; _softwarePte = record.IsSoftware ? "yes" : "no"; }
private FoundDevice BuildResponse(AddressRecord aRecord, TXTRecord tXTRecord) { var IpAddress = aRecord.Address.ToString(); var DeviceId = aRecord.Name.Labels[0].Replace("-", ""); var DeviceName = Utils.Common; if (tXTRecord != null) { var prop = tXTRecord.Strings.Find(x => x.Contains("fn")); if (prop != null) { var info = prop.Split("="); DeviceName = info[1] ?? Utils.Common; } else { DeviceName = aRecord.Name.Labels[0]; } } else { DeviceName = aRecord.Name.Labels[0]; } return(new FoundDevice { IpAddress = IpAddress, DeviceId = DeviceId, DeviceName = DeviceName, FoundAt = aRecord.CreationTime, FoundUsing = "MDNS" }); }
public AddressEditViewModel() { AddressRecord = new AddressRecord(); Errors = new List <string>(); Information = new List <string>(); }
public Contact(string name, AddressRecord address, string phone, string email) { Name = name; Address = address; Phone = phone; Email = email; }
/// <summary> /// Creates a new instance of the <see cref="ServiceProfile"/> class /// with the specified details. /// </summary> /// <param name="instanceName"> /// A unique identifier for the specific service instance. /// </param> /// <param name="serviceName"> /// The <see cref="ServiceName">name</see> of the service. /// </param> /// <param name="port"> /// The TCP/UDP port of the service. /// </param> /// <param name="addresses"> /// The IP addresses of the specific service instance. If <b>null</b> then /// <see cref="MulticastService.GetIPAddresses"/> is used. /// </param> /// <remarks> /// The SRV, TXT and A/AAAA resoruce records are added to the <see cref="Resources"/>. /// </remarks> public ServiceProfile(DomainName instanceName, DomainName serviceName, ushort port, IEnumerable <IPAddress> addresses = null) { InstanceName = instanceName; ServiceName = serviceName; var fqn = FullyQualifiedName; var simpleServiceName = new DomainName(ServiceName.ToString() .Replace("._tcp", "") .Replace("._udp", "") .Trim('_') .Replace("_", "-")); HostName = DomainName.Join(InstanceName, simpleServiceName, Domain); Resources.Add(new SRVRecord { Name = fqn, Port = port, Target = HostName }); Resources.Add(new TXTRecord { Name = fqn, Strings = { "txtvers=1" } }); foreach (var address in addresses ?? MulticastService.GetLinkLocalAddresses()) { Resources.Add(AddressRecord.Create(HostName, address)); } }
private void Delete(AddressRecord address) { if (address != null) { _addressRecord.Delete(address); } }
public void CanonicalOrder() { var catalog = new Catalog { AddressRecord.Create("*.z.example", IPAddress.Loopback), AddressRecord.Create("a.example", IPAddress.Loopback), AddressRecord.Create("yljkjljk.a.example", IPAddress.Loopback), AddressRecord.Create("Z.a.example", IPAddress.Loopback), AddressRecord.Create("zABC.a.EXAMPLE", IPAddress.Loopback), AddressRecord.Create("z.example", IPAddress.Loopback), AddressRecord.Create("!.z.example", IPAddress.Loopback), AddressRecord.Create("~.z.example", IPAddress.Loopback), AddressRecord.Create("example", IPAddress.Loopback) }; var expected = new DomainName[] { "example", "a.example", "yljkjljk.a.example", "Z.a.example", "zABC.a.EXAMPLE", "z.example", "!.z.example", "*.z.example", "~.z.example" }; var actual = catalog .NodesInCanonicalOrder() .Select(node => node.Name) .ToArray(); CollectionAssert.AreEqual(expected, actual); }
public async Task Update_address() { // arrange var customer = NewCustomer(); // act await DataAccessClient.CreateCustomerAsync(customer); var address = new AddressRecord { Label = "Work", Street = "101 W. Broadway", City = "San Diego", State = "CA" }; await DataAccessClient.AddOrUpdateAddressAsync(customer.Username, address); var result = await Table.GetItemAsync(customer.GetPrimaryKey(), consistentRead : true); // assert result.Username.Should().Be(customer.Username); result.Name.Should().Be(customer.Name); result.EmailAddress.Should().Be(customer.EmailAddress); result.Addresses.Should().NotBeEmpty(); result.Addresses.Should().ContainKey("Work"); result.Addresses["Work"].Should().BeEquivalentTo(address); }
private AddressEditViewModel CreateVM(AddressRecord address) { // defaults to "no country selected" for a new or "legacy" AddressRecord var countryId = address.CountryId; if (countryId == 0 && !string.IsNullOrWhiteSpace(address.Country)) { // from address.Country, find the value that should be used // address.Country is of type string. It could represent the // name of the country (legacy) or the Id of the country territory. // Try to parse it. if (!int.TryParse(address.Country, out countryId)) { // parsing failed, so the string may be a territory's name var tp = _addressConfigurationService.GetCountry(address.Country); if (tp != null) { countryId = tp.Record.TerritoryInternalRecord.Id; } } } return(new AddressEditViewModel(address) { Countries = _addressConfigurationService .CountryOptions(address.AddressType, countryId), CountryId = countryId }); }
private void StoreAddress(Address address, string typeAddress, ContentItem contact) { var typeAddressValue = (AddressRecordType)Enum.Parse(typeof(AddressRecordType), typeAddress); Mapper.Initialize(cfg => { cfg.CreateMap <Address, AddressRecord>(); }); var addressToStore = new AddressRecord(); Mapper.Map <Address, AddressRecord>(address, addressToStore); addressToStore.AddressType = typeAddressValue; addressToStore.NwazetContactPartRecord_Id = contact.Id; bool AddNewAddress = true; foreach (var existingAddressRecord in contact.As <NwazetContactPart>().NwazetAddressRecord) { if (addressToStore.Equals(existingAddressRecord)) { AddNewAddress = false; existingAddressRecord.TimeStampUTC = DateTime.UtcNow; _addressRecord.Update(existingAddressRecord); _addressRecord.Flush(); } } if (AddNewAddress) { _addressRecord.Create(addressToStore); _addressRecord.Flush(); } }
public async Task <IActionResult> Create([Bind("FirstName,LastName,Email,ImagePath,ImageData,Address1,Address2,City,State,ZipCode,PhoneNumber,Created,Updated,Note")] AddressRecord addressRecord, IFormFile imageData) { if (ModelState.IsValid) { if (imageData != null) { addressRecord.ImagePath = imageData.FileName; addressRecord.ImageData = AvatarHelper.EncodeImage(imageData); } addressRecord.Created = DateTime.Now; var truncPhone = addressRecord.PhoneNumber .Replace(" ", "") .Replace("(", "") .Replace(")", "") .Replace("-", ""); var formatedPhone = $"({truncPhone.Substring(0, 3)}) {truncPhone.Substring(3, 3)}-{truncPhone.Substring(6, 4)}"; addressRecord.PhoneNumber = formatedPhone; _context.Add(addressRecord); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(addressRecord)); }
private void StoreAddress(AddressRecord addressToStore, ContentItem contact) { addressToStore.NwazetContactPartRecord_Id = contact.Id; bool AddNewAddress = true; foreach (var existingAddressRecord in contact.As <NwazetContactPart>().NwazetAddressRecord) { if (addressToStore.Id == existingAddressRecord.Id || addressToStore.Equals(existingAddressRecord)) { AddNewAddress = false; existingAddressRecord.TimeStampUTC = DateTime.UtcNow; // little trick to cause nHibernate to "replace" the old address // with the updated one: addressToStore.Id = existingAddressRecord.Id; _addressRecord.Update(addressToStore); _addressRecord.Flush(); } } if (AddNewAddress) { _addressRecord.Create(addressToStore); _addressRecord.Flush(); } }
public static AnswerRecord ReadAnswerRecord(byte[] bBuffer, int startIndex) { AnswerRecord retval = new AnswerRecord(); retval.mOriginalBuffer = new byte[bBuffer.Length]; retval.mStartIndex = startIndex; Array.Copy(bBuffer, 0, retval.mOriginalBuffer, 0, bBuffer.Length); UInt16 i = GetUInt16(bBuffer, startIndex); int offset = 0; if (i > 0xc000) { retval.mName = GetNameAtLocation(bBuffer, i - 0xc000); offset = 2; } else { retval.Name = GetNameAtLocation(bBuffer, i); offset = i; } retval.mNameBufferLength = GetLabelLength(bBuffer, startIndex); retval.mType = GetUInt16(bBuffer, startIndex + offset); retval.mClass = GetUInt16(bBuffer, startIndex + offset + 2); retval.TTL = GetUInt32(bBuffer, startIndex + offset + 4); UInt16 RDLength = GetUInt16(bBuffer, startIndex + offset + 8); retval.mData = new byte[RDLength]; Array.Copy(bBuffer, startIndex + offset + 10, retval.mData, 0, RDLength); retval.mLength = offset + RDLength + 10; if (retval.Type == (UInt16)TYPECODE.NS) { retval = new NameServerRecord(retval); } if (retval.Type == (UInt16)TYPECODE.A) { retval = new AddressRecord(retval); } if (retval.Type == (UInt16)TYPECODE.MX) { retval = new MailExchangeRecord(retval); } if (retval.Type == (UInt16)TYPECODE.CNAME) { retval = new CanonicalNameRecord(retval); } if (retval.Type == (UInt16)TYPECODE.SOA) { retval = new StartOfAuthorityRecord(retval); } if (retval.Type == (UInt16)TYPECODE.TXT) { retval = new TextRecord(retval); } if (retval.Type == (UInt16)TYPECODE.PTR) { retval = new PointerRecord(retval); } return(retval); }
public static string DecodeImage(AddressRecord record) { var binary = Convert.ToBase64String(record.ImageData); var ext = Path.GetExtension(record.ImagePath); string imageDataUrl = $"data:image/{ext};base64,{binary}"; return(imageDataUrl); }
public bool ShouldTestForValidity(string postcode) { var emp = new AddressRecord() { Postcode = postcode }; return(emp.IsValidPostCode()); }
public static void UpdateByViewModel(AddressRecord record, AddressVm addressVm) { record.Address = addressVm.Address.TrimIt().StripTags(); record.Latitude = addressVm.Latitude; record.Longitude = addressVm.Longitude; record.Tip = addressVm.Tip.TrimIt().StripTags(); record.IsDeleted = addressVm.Destroy; }
public void ParseAddress() { var items = SIERecord.ParseLine(@"#ADRESS ""SvenSvensson"" ""Box 21"" ""21120 MALM�"" ""040 - 12345"""); var record = new AddressRecord(); record.Read(items); Assert.Equal("040 - 12345", record.PhoneNumber); }
private void AnswerReceived(Message message) { List <PTRRecord> answers = message.Answers.Where(a => a.Name == AtemDeviceInfo.ServiceName).OfType <PTRRecord>().ToList(); PTRRecord answer = answers.FirstOrDefault(); if (answer == null) { return; } if (_debug && answers.Count != 1) { Console.WriteLine("Too many answers!"); } List <ResourceRecord> records = message.AdditionalRecords; SRVRecord srvRec = records.OfType <SRVRecord>().FirstOrDefault(r => r.Type == DnsType.SRV && r.Name == answer.DomainName); if (srvRec == null) { if (_debug) { Console.WriteLine("Missing SRV record for " + answer.DomainName); } return; } AddressRecord aRec = records.OfType <AddressRecord>().FirstOrDefault(r => r.Type == DnsType.A && r.Name == srvRec.Target); if (aRec == null) { if (_debug) { Console.WriteLine("Missing A record for " + answer.DomainName); } return; } TXTRecord txtRec = records.OfType <TXTRecord>().FirstOrDefault(r => r.Type == DnsType.TXT && r.Name == answer.DomainName); List <string> strings = txtRec == null ? new List <string>() : txtRec.Strings; string name = string.Join(".", answer.DomainName.Labels); if (name.EndsWith(AtemDeviceInfo.ServiceName)) { name = name.Substring(0, name.Length - AtemDeviceInfo.ServiceName.Length - 1); } var dev = new AtemDeviceInfo(name, srvRec.Target.ToString(), DateTime.Now, aRec.Address.ToString(), srvRec.Port, strings); lock (_knownDevices) { _knownDevices[dev.DeviceId] = dev; } OnDeviceSeen?.Invoke(this, dev); }
internal async Task GetIpAddressAsync_Preference_IsRespected(IpAddressMode ipAddressMode, AddressFamily expectedFamily) { // Arrange var ipv4Record = new AddressRecord( new ResourceRecordInfo("cb.somewhere.com.", ResourceRecordType.A, QueryClass.IN, 100, 100), IPAddress.Parse("127.0.0.1")); var mockIpv4Response = new Mock <IDnsQueryResponse>(); mockIpv4Response .Setup(x => x.HasError).Returns(false); mockIpv4Response .Setup(x => x.Answers) .Returns(new List <AddressRecord> { ipv4Record }); var ipv6Record = new AddressRecord( new ResourceRecordInfo("cb.somewhere.com.", ResourceRecordType.AAAA, QueryClass.IN, 100, 100), IPAddress.Parse("::1")); var mockIpv6Response = new Mock <IDnsQueryResponse>(); mockIpv6Response .Setup(x => x.HasError).Returns(false); mockIpv6Response .Setup(x => x.Answers) .Returns(new List <AddressRecord> { ipv6Record }); var mockLookupClient = new Mock <ILookupClient>(); mockLookupClient .Setup(x => x.QueryAsync("cb.somewhere.com.", QueryType.A, QueryClass.IN, default)) .ReturnsAsync(mockIpv4Response.Object); mockLookupClient .Setup(x => x.QueryAsync("cb.somewhere.com.", QueryType.AAAA, QueryClass.IN, default)) .ReturnsAsync(mockIpv6Response.Object); var resolver = new DnsClientDnsResolver(mockLookupClient.Object, new Mock <ILogger <DnsClientDnsResolver> >().Object) { IpAddressMode = ipAddressMode }; // Act var result = await resolver.GetIpAddressAsync("cb.somewhere.com"); // Assert Assert.NotNull(result); Assert.Equal(expectedFamily, result.AddressFamily); }
internal static Address GetEntity(this AddressRecord address) { return(address == null ? null : new Address() { City = address.City, Note = address.Note, Street = address.Street, ZipCode = address.ZipCode }); }
public void TestA(string name, string ip) { IPAddress original = IPAddress.Parse(ip); AddressRecord record = new AddressRecord(name, original.ToIPV4()); Assert.True(record.IPAddress.Equals(original)); AddressRecord parsedRecord = this.Roundtrip <AddressRecord>(record); Assert.True(parsedRecord.Equals(record)); }
private static Address CreateDataContract(AddressRecord record) { var result = new Address { AddressText = record.Address, Latitude = record.Latitude, Longitude = record.Longitude, Tip = record.Tip }; return(result); }
public async Task <AddOrUpdateAddressResponse> AddOrUpdateAddressAsync(string customerUsername, string addressLabel, AddOrUpdateAddressRequest request) { var address = new AddressRecord { Label = addressLabel, City = request.City, State = request.State, Street = request.Street }; await DataAccessClient.AddOrUpdateAddressAsync(customerUsername, address); return(new AddOrUpdateAddressResponse()); }
private void StoreAddress(Address address, string typeAddress, ContentItem contact) { var typeAddressValue = (AddressRecordType)Enum.Parse(typeof(AddressRecordType), typeAddress); Mapper.Initialize(cfg => { cfg.CreateMap <Address, AddressRecord>(); }); var addressToStore = new AddressRecord(); Mapper.Map <Address, AddressRecord>(address, addressToStore); addressToStore.AddressType = typeAddressValue; StoreAddress(addressToStore, contact); }
public static AddressRecord GetAddress(int addressId) { String query = $"SELECT * FROM addresses WHERE addressId={addressId}"; DataTable addresses = connector.ExecuteQuery(query); var record = new AddressRecord(); if (addresses.Rows.Count == 0) { return(null); } record.Fill(addresses.Rows[0]); return(record); }
public static AddressRecord GetAddress(int clientId, String country, String city, String street, int ZIPCode, int buildingNumber, String apartmentNumber) { var query = $"SELECT * FROM addresses WHERE clientId={clientId} and country='{country}' and city='{city}' and street='{street}' and ZIPCode={ZIPCode} and buildingNumber={buildingNumber} and apartmentNumber='{apartmentNumber}'"; var addresses = connector.ExecuteQuery(query); if (addresses.Rows.Count == 0) { return(null); } var record = new AddressRecord(); record.Fill(addresses.Rows[0]); return(record); }
public static List <AddressRecord> GetAddresses(int clientId) { List <AddressRecord> addressRecords = new List <AddressRecord>(); String query = $"SELECT * FROM addresses WHERE clientId={clientId}"; DataTable addresses = connector.ExecuteQuery(query); foreach (DataRow dr in addresses.Rows) { var record = new AddressRecord(); record.Fill(dr); addressRecords.Add(record); } return(addressRecords); }
/// <inheritdoc /> public override void AddAddress(AddressRecord record) { var builder = new StringBuilder(512); // The CSV format of the PAF has a 490 maximum OrganisationRecord organisation = GetRelated(record.OrganisationKey, this.organisations); if (organisation != null) { builder.Append(organisation.Name) .Append(' ') .Append(organisation.Department) .Append(' '); } if (record.BuildingNumber != null) { builder.Append(record.BuildingNumber) .Append(' '); } builder.Append(GetRelated(record.BuildingNameKey, this.buildingNames)) .Append(' ') .Append(GetRelated(record.SubBuildingNameKey, this.subBuildingNames)) .Append(' '); builder.Append(GetRelated(record.DependentThoroughfareKey, this.thoroughfares)) .Append(' ') .Append(GetRelated(record.DependentThoroughfareDescriptorKey, this.descriptors)) .Append(' ') .Append(GetRelated(record.ThoroughfareKey, this.thoroughfares)) .Append(' ') .Append(GetRelated(record.ThoroughfareDescriptorKey, this.descriptors)) .Append(' ') .Append(record.POBoxNumber) .Append(' '); LocalityRecord locality = GetRelated(record.LocalityKey, this.localities); if (locality != null) { builder.Append(locality.DoubleDependentLocality) .Append(' ') .Append(locality.DependentLocality) .Append(' ') .Append(locality.PostTown); } this.addresses[record.Key] = builder.ToString(); }
public DnsRecord ParseANAME(string[] args) { string domainName = args.GetRequiredValue(0); string ipAddress = args.GetRequiredValue(1); int ttl = this.ValidateTTL(args.GetOptionalValue <int>(2, 0)); string notes = args.GetOptionalValue(3, string.Empty); AddressRecord record = new AddressRecord(domainName , ipAddress) { TTL = ttl }; return(new DnsRecord(domainName, DnsStandard.RecordType.ANAME, record.Serialize(), notes)); }