Пример #1
0
        /// <summary>
        /// Extracts the <see cref="System.Net.IPAddress"/> from a record of type
        /// <see cref="AK.Net.Dns.DnsRecordType.A"/> or
        /// <see cref="AK.Net.Dns.DnsRecordType.Aaaa"/>.
        /// </summary>
        /// <param name="record">The record.</param>
        /// <returns>The extracted <see cref="System.Net.IPAddress"/>.</returns>
        /// <exception cref="System.ArgumentException">
        /// Thrown when the <paramref name="record"/> cannot be converted to an IP address.
        /// </exception>
        public static IPAddress ToIP(DnsRecord record)
        {
            if (record == null)
            {
                return(null);
            }

            switch ((DnsRecordType)record.Type)
            {
            case DnsRecordType.A:
                return(ToA(record).Address);

            case DnsRecordType.Aaaa:
                return(ToAaaa(record).Address);

            default:
                throw Guard.DnsRecordMustBeAorAaaa("record");
            }
        }
Пример #2
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.Loc"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.Loc"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsLoc(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.Loc));
 }
Пример #3
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.Soa"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.Soa"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsSoa(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.Soa));
 }
Пример #4
0
 private static bool IsOfType(DnsRecord record, DnsRecordType type)
 {
     return(record != null && record.Type == type);
 }
Пример #5
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.XRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.XRecord"/>.</returns>
 public static XRecord ToX(DnsRecord record)
 {
     return((XRecord)record);
 }
Пример #6
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.MGRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.MGRecord"/>.</returns>
 public static MGRecord ToMG(DnsRecord record)
 {
     return((MGRecord)record);
 }
Пример #7
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.SrvRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.SrvRecord"/>.</returns>
 public static SrvRecord ToSrv(DnsRecord record)
 {
     return((SrvRecord)record);
 }
Пример #8
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.NS"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.NS"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsNS(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.NS));
 }
Пример #9
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.HInfoRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.HInfoRecord"/>.</returns>
 public static HInfoRecord ToHInfo(DnsRecord record)
 {
     return((HInfoRecord)record);
 }
Пример #10
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.CNameRecord"/>.
 /// </summary>
 /// <param name="record">The record to wrap.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.CNameRecord"/>.</returns>
 public static CNameRecord ToCName(DnsRecord record)
 {
     return((CNameRecord)record);
 }
Пример #11
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.A"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.A"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsA(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.A));
 }
Пример #12
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.AaaaRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.AaaaRecord"/>.</returns>
 public static AaaaRecord ToAaaa(DnsRecord record)
 {
     return((AaaaRecord)record);
 }
Пример #13
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.ARecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.ARecord"/>.</returns>
 public static ARecord ToA(DnsRecord record)
 {
     return((ARecord)record);
 }
Пример #14
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.A"/> or
 /// <see cref="AK.Net.Dns.DnsRecordType.Aaaa"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.A"/> or
 /// <see cref="AK.Net.Dns.DnsRecordType.Aaaa"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsAOrAaaa(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.A) ||
            IsOfType(record, DnsRecordType.Aaaa));
 }
Пример #15
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.DN"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.DN"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsDN(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.DN));
 }
Пример #16
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.SoaRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.SoaRecord"/>.</returns>
 public static SoaRecord ToSoa(DnsRecord record)
 {
     return((SoaRecord)record);
 }
Пример #17
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.TxtRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.TxtRecord"/>.</returns>
 public static TxtRecord ToTxt(DnsRecord record)
 {
     return((TxtRecord)record);
 }
Пример #18
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.MInfoRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.MInfoRecord"/>.</returns>
 public static MInfoRecord ToMInfo(DnsRecord record)
 {
     return((MInfoRecord)record);
 }
Пример #19
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.WksRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.WksRecord"/>.</returns>
 public static WksRecord ToWks(DnsRecord record)
 {
     return((WksRecord)record);
 }
Пример #20
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.MXRecord"/>.
 /// </summary>
 /// <param name="record">The record to wrap.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.MXRecord"/>.</returns>
 public static MXRecord ToMX(DnsRecord record)
 {
     return((MXRecord)record);
 }
Пример #21
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.MBRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.MBRecord"/>.</returns>
 public static MBRecord ToMB(DnsRecord record)
 {
     return((MBRecord)record);
 }
Пример #22
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.NSRecord"/>.
 /// </summary>
 /// <param name="record">The record to wrap.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.NSRecord"/>.</returns>
 public static NSRecord ToNS(DnsRecord record)
 {
     return((NSRecord)record);
 }
Пример #23
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.MRRecord"/>.
 /// </summary>
 /// <param name="record">The record to cast.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.MRRecord"/>.</returns>
 public static MRRecord ToMR(DnsRecord record)
 {
     return((MRRecord)record);
 }
Пример #24
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.DNRecord"/>.
 /// </summary>
 /// <param name="record">The record to wrap.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.DNRecord"/>.</returns>
 public static DNRecord ToDN(DnsRecord record)
 {
     return((DNRecord)record);
 }
Пример #25
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.SpfRecord"/>.
 /// </summary>
 /// <param name="record">The record to wrap.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.SpfRecord"/>.</returns>
 public static SpfRecord ToSpf(DnsRecord record)
 {
     return((SpfRecord)record);
 }
Пример #26
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.NullRecord"/>.
 /// </summary>
 /// <param name="record">The record to wrap.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.NullRecord"/>.</returns>
 public static NullRecord ToNull(DnsRecord record)
 {
     return((NullRecord)record);
 }
Пример #27
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.CName"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.CName"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsCName(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.CName));
 }
Пример #28
0
 /// <summary>
 /// Casts the specified <paramref name="record"/> to type
 /// <see cref="AK.Net.Dns.Records.PtrRecord"/>.
 /// </summary>
 /// <param name="record">The record to wrap.</param>
 /// <returns>The specified <paramref name="record"/> cast to type
 /// <see cref="AK.Net.Dns.Records.PtrRecord"/>.</returns>
 public static PtrRecord ToPtr(DnsRecord record)
 {
     return((PtrRecord)record);
 }
Пример #29
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.MB"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.MB"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsMB(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.MB));
 }
Пример #30
0
 /// <summary>
 /// Returns a value indicating if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.RT"/>.
 /// </summary>
 /// <param name="record">The record to test.</param>
 /// <returns><see langword="true"/> if the record is of type
 /// <see cref="AK.Net.Dns.DnsRecordType.RT"/>, otherwise;
 /// <see langword="false"/>.</returns>
 public static bool IsRT(DnsRecord record)
 {
     return(IsOfType(record, DnsRecordType.RT));
 }