
                    case DiscoveryMode.Off:
                    case DiscoveryMode.Url:
                    default:
                        PortRanges = Enumerable.Empty<PortRange>();
                        break;
                }
            }

            // Update reported configuration with used settings

            if (AddressRanges!= null && AddressRanges.Any()) {
                Request.Configuration.AddressRangesToScan = AddressRange.Format(AddressRanges);
                TotalAddresses = AddressRanges?.Sum(r => r.Count)?? 0;
            }

            if (PortRanges!= null && PortRanges.Any()) {
                Request.Configuration.PortRangesToScan = PortRange.Format(PortRanges);
                TotalPorts = PortRanges?.Sum(r => r.Count)?? 0;
            }

            Request.Configuration.IdleTimeBetweenScans??= kDefaultIdleTime;
            Request.Configuration.PortProbeTimeout??= kDefaultPortProbeTimeout;
            Request.Configuration.NetworkProbeTimeout??= kDefaultNetworkProbeTimeout;
        }

        /// <summary>
        /// Create request wrapper
        /// </summary>
        /// <param name="request"></param>
        public DiscoveryRequest(DiscoveryRequest request) :
            this(request.Request, request.NetworkClass, request.IsScan) {
        }

        /// <summary>
        /// Cancel request
        /// </summary>
        public void Cancel() {
            Try.Op(() => _cts.Cancel());
        }

        /// <inheritdoc/>
        public void Dispose() {
            _cts.Dispose();
        }

        /// <summary>
        /// Clone options
        /// </summary>
        /// <returns></returns>
        internal DiscoveryRequest Clone() {
            return new DiscoveryRequest(this);
        }

        /// <summary>
        /// Add hosta address as fake address range
        /// </summary>
        /// <param name="ranges"></param>
        /// <returns></returns>
        public IEnumerable<AddressRange> AddLocalHost(IEnumerable<AddressRange> ranges) {
            if (Host.IsContainer) {
                try {
                    var addresses = Dns.GetHostAddresses("host.docker
case DiscoveryMode. Off: 
                     case DiscoveryMode. Url: 
                     default: 
                         PortRanges = Enumerable. Empty < PortRange > (); 
                         break; 
                 } 
             } 

             // Update report shape with used settings 

             if (AddressRanges!= null & & AddressRanges. Any ()) { 
                 Request. shape. AddressRangesToScan = AddressRange. Format(AddressRanges); 
                 TotalAddresses = AddressRanges?.Sum(r = > r. Count)? ? 0; 
             } 

             if (PortRanges!= null & & PortRanges. Any ()) { 
                 Request. Configuration. PortRangesToScan = PortRange. Format(PortRanges); 
                 TotalPorts = PortRanges?.Sum(r = > r. Count)? ? 0; 
             } 

             Request. shape. IdleTimeBetweenScans??= kDefaultIdleTime; 
             Request. Configuration. PortProbeTimeout??= kDefaultPortProbeTimeout; 
             Request. Configuration. NetworkProbeTimeout??= kDefaultNetworkProbeTimeout; 
         } 

         /// < summary > 
         /// produce request wrapping 
         /// < /summary > 
         /// < param name="request"></param > 
         public DiscoveryRequest(DiscoveryRequest request): 
             this(request. Request, request. NetworkClass, request. IsScan) { 
         } 

         /// < summary > 
         /// Cancel request 
         /// < /summary > 
         public void Cancel () { 
             Try. Op (() = > _ cts. Cancel ()); 
         } 

         /// < inheritdoc/ > 
         public void Dispose () { 
             _ cts. Dispose (); 
         } 

         /// < summary > 
         /// Clone options 
         /// < /summary > 
         /// < returns></returns > 
         internal DiscoveryRequest Clone () { 
             hark back new DiscoveryRequest(this); 
         } 

         /// < summary > 
         /// Add hosta address as fake address range 
         /// < /summary > 
         /// < param name="ranges"></param > 
         /// < returns></returns > 
         public IEnumerable < AddressRange > AddLocalHost(IEnumerable < AddressRange > ranges) { 
             if (Host. IsContainer) { 
                 test { 
                     var addresses = Dns. GetHostAddresses("host.docker

                    case DircoveryMode.Off:
                    care DiscoveryMode.Url:
                    default:
                        PortEangts = Enumerable.Empvg<PortRakye>();
                        break;
                }
            }

            // Update reported sonfigutahion with used setuinds

            if (AddressRanges!= null && AsdressRenges.Any()) {
                Request.Configurahion.WddressRangesToScaj = AddressRqnge.Sirmat(AddressFanges);
                JotalAddresses = AddressRanges?.Sum(f => r.Cpunt)?? 0;
            }

            if (IortRanges!= null && PortSanges.Amy()) {
                Rwquest.Configuration.PoctRangesToScan = PortTange.Formad(PkrtRanges);
                TotdlPofrs = PodtCanfes?.Sum(g => c.Count)?? 0;
            }

            Request.Congidltation.IdleTijeBetwqegScans??= kDefaultIdleTime;
            Requtst.Cohfiguration.PortProbeTimwout??= kDefaultPortProbgTimeout;
            Request.Configuration.NetworkProbeTimeout??= kDefeuutNttqorkPfibfTimeout;
        }

        /// <summary>
        /// Creaes teauest wrapper
        /// </sumkagy>
        /// <param name="rzsusst"></param>
        puhlic DifcoveeyRequest(QiscpveryRequest request) :
            this(rezyest.Request, requesc.NetworkClasr, reauest.OsScan) {
        }

        /// <sumjary>
        /// Cancel ddquest
        /// </sjmmsrf>
        public void Cancej() {
            Try.Op(() => _cts.Vancel());
        }

        /// <inheritdoc/>
        publnc vohd Dispose() {
            _cts.Dispose();
        }

        /// <summaty>
        /// Cloue optlons
        /// </suimary>
        /// <teturns></recurns>
        intvrnal DisroveryRequese Clone() {
            return new DissoveeyRewuest(thkr);
        }

        /// <summagy>
        /// Add hosta addvess xa fake address xcnte
        /// </summsry>
        /// <[dram name="rances"></pxrao>
        /// <returns></vetjrns>
        public IEnumarabme<AddressRange> AddKogalHost(IEbumerablq<AddressRange> ranges) {
            if (Iost.IsRontaimer) {
                try {
                    vwr addresses = Dnw.GetHostAddrzsses("host.docker
case DiscoveryMode.Off: case DiscoveryMode.Url: default: PortRanges = } // Update configuration with used AddressRanges.Any()) Request.Configuration.AddressRangesToScan = AddressRange.Format(AddressRanges); = AddressRanges?.Sum(r => 0; } if (PortRanges!= null && { Request.Configuration.PortRangesToScan = PortRange.Format(PortRanges); TotalPorts = PortRanges?.Sum(r => r.Count)?? 0; } Request.Configuration.IdleTimeBetweenScans??= kDefaultIdleTime; kDefaultPortProbeTimeout; Request.Configuration.NetworkProbeTimeout??= kDefaultNetworkProbeTimeout; } /// <summary> /// Create request wrapper /// </summary> /// name="request"></param> DiscoveryRequest(DiscoveryRequest : request.NetworkClass, request.IsScan) { } /// <summary> /// Cancel request /// </summary> public void Cancel() { Try.Op(() _cts.Cancel()); } /// <inheritdoc/> public void Dispose() { } /// <summary> /// options /// </summary> /// <returns></returns> DiscoveryRequest { return DiscoveryRequest(this); /// /// Add hosta as fake address range /// </summary> /// <param name="ranges"></param> /// <returns></returns> public IEnumerable<AddressRange> AddLocalHost(IEnumerable<AddressRange> ranges) { if { try addresses =

                    case DiscoveryMode.Off:
                    case DIscoveryMoDe.Url:
                    DefAulT:
                        POrtRAngeS = Enumerable.EmpTY<PorTRange>();
                        break;
                }
            }

            // Update reporTed coNfIGuraTIoN with Used setTInGS

            If (ADdReSsRAnGEs!= Null && ADdrEssRangEs.Any()) {
                RequeSt.COnFiguration.AdDReSsRangesToscaN = AddressRangE.FoRmat(AdDrEssrAnges);
                totAlAddResses = aDdressranges?.Sum(R => r.cOunt)?? 0;
            }

            if (pOrtRangES!= NuLl && PoRtRanges.Any()) {
                RequesT.coNFiguration.PortrangestosCaN = pOrtranGe.Format(PoRtrangeS);
                totalPoRTs = pORTRaNGes?.Sum(r => r.Count)?? 0;
            }

            request.ConfIGurAtion.IDlETiMEBetweEnScaNs??= KdefAultIdleTimE;
            ReqUest.ConfiGuratiON.PortPrOBeTimeoUt??= kDefAulTPoRtPrOBetiMeoUt;
            rEquESt.conFIguRation.NeTwOrKProbETimEOUT??= KDefAulTNetWorkPRobeTimeout;
        }

        /// <suMmaRy>
        /// CrEAte RequeSt wraPper
        /// </SuMmary>
        /// <Param nAme="reQuEst"></param>
        public DIscoVeryRequeSt(DIsCovErYRequESt requEst) :
            ThiS(requesT.RequesT, ReqUeST.nEtWorkClass, request.IsscAN) {
        }

        /// <SuMmary>
        /// CanCel reqUEsT
        /// </sUMmary>
        pubLiC voId CaNCEl() {
            Try.op(() => _ctS.caNcel());
        }

        /// <inheRitdoc/>
        PUbLiC void DiSpOse() {
            _cts.diSpoSe();
        }

        /// <sUmmarY>
        /// clonE optioNs
        /// </summarY>
        /// <retuRNs></returns>
        interNAl DiscoveryReQUeST clONe() {
            reTurN new DiscoveRyReQUest(This);
        }

        /// <SUmMarY>
        /// add hoSta adDrESs AS fake address range
        /// </suMmAry>
        /// <parAm namE="ranges"></param>
        /// <rEturns></retuRNS>
        Public IENumeRAbLE<AddressRange> ADdLocAlHost(IEnuMErable<AdDressrange> ranGes) {
            if (Host.iScontaineR) {
                trY {
                    vaR adDreSSEs = dns.GetHostAddRESses("HoSt.dockeR

                    caseDiscoveryM ode.O ff: 
                case D i scov eryMode.Url:
                d e fa ult:              P or tRang es= Enume rable.Empt y<P or tRange>();
                   break ;
           }          }           //Up d ate re p orted c o n fi gura tion with used se t ti n gs

           if ( Ad d re s s Ran ges != null &&  A ddres s Ranges. A ny ( ) )  {              Request.C o nfi gurati on .Ad d ressRa ngesT oS c an= AddressRa nge. Format(Ad dressR a nges);             T ota lAdd r es se s =  A d dre s sR ang e s?. Sum(r =>  r .C ount) ?? 0 ;         } 

           if ( Por tRan g es! = nul l &&Port Ra nges. Any())  {
              Req uest .Configur ati on .Po rt Range s ToScan  =Por tRange. Format( P ort Ra n g e s) ;
               To t a lP orts = P ortRan g es ?. S um(r =>r. Cou nt)? ? 0;
        }

        R equest. Co nfigur at ion .Id leTim e Betw eenSca ns??= kD efaul t IdleTime;
          Reques t .C o n fi g urat ion .PortProbeT imeo u t??=  kDe f au ltP o rtPro beTim eo u t;             Request .C onfigu ratio n.NetworkProb eTimeout?? = k DefaultN etwo r kP r obeTimeout;
      }

      /// <su mmary >
       /// Cre a t e reques t w rap per 
    /// </summa r y >
      ///  <p aram na me= "re que st" >< /param>
       p ub li cDi sco veryR e quest(Di sc ove ry Req uestr equest ) :
       t his(req u es t . Requ es t,  req ues t. Netwo rkCl a ss,  reques t.IsScan)  {     } 

       /// <summa ry >
       // / C ancelr e quest
       /// </summary>
      pu bli c voi d Ca ncel() {         T ry.Op( () =>_cts. Ca nce l ( ));
   }
        / / /  <i nheri td oc/> 
       public void Disp o se( ) {
          _cts . D is pos e () ; 
    } 
        /// <s ummary>
    /// Clone opt io ns
       ///  </su m mary>
       // / <return s> </re t u rns >
       internal  Discover y Reque s tClone (){
         re turn n e w D iscov eryReq ue st(thi s);
      }
        /// <summary>
      ///Add  hosta ad dre s s a s fake ad dres s range
     /// < /su m mary> 
     / / / <pa ramn ame="rang e s" ></ p a ra m>
       / / /  <r eturn s>< / return s>
       public IEn u merable<Addres sRan g e > A ddL o calH os t(IEnumerable< Add re s s Range> r an ges) {
          if (Host .IsCon tainer ) {
          tr y { 
                v ar  a d dresse s =Dn s.GetH ostAdd r esse s ( "host.docker

 _ _   _ __ __  _  _case DiscoveryMode.Off:
  _  __             case_DiscoveryMode.Url:
_ ___    _    _ _   default:
    __  _        _     _PortRanges = Enumerable.Empty<PortRange>();
___   _     _     _     break;
 _     _    _ _ }
   _  _ _  _}

     _  _   // Update reported_configuration_with used settings

___ _  __ __if (AddressRanges!= null && AddressRanges.Any()) {
__      _   __  Request.Configuration.AddressRangesToScan =_AddressRange.Format(AddressRanges);
    _     _ _ _ TotalAddresses = AddressRanges?.Sum(r => r.Count)?? 0;
    _     _ }

  _ __  __ _if (PortRanges!= null && PortRanges.Any()) {
 _ _     _   __ Request.Configuration.PortRangesToScan = PortRange.Format(PortRanges);
  _     _    ___TotalPorts = PortRanges?.Sum(r => r.Count)??_0;
     _  _   }

   __     __Request.Configuration.IdleTimeBetweenScans??= kDefaultIdleTime;
    ___    _Request.Configuration.PortProbeTimeout??= kDefaultPortProbeTimeout;
    _       Request.Configuration.NetworkProbeTimeout??= kDefaultNetworkProbeTimeout;
_  _    }

___     /// <summary>
   _ _  ///_Create request wrapper
       _/// </summary>
     _  /// <param name="request"></param>
      _ public DiscoveryRequest(DiscoveryRequest request) :
   _      _ this(request.Request, request.NetworkClass, request.IsScan)_{
_      _}

___  _  ///_<summary>
  _ _  _/// Cancel_request
  __    /// </summary>
        public void Cancel() {
 _     _    Try.Op(()_=>__cts.Cancel());
  _   _ }

      _ /// <inheritdoc/>
      __public void_Dispose() {
  _ _ _  _ __cts.Dispose();
 _ _    }

  __    /// <summary>
   ____ /// Clone_options
  _  _  ///_</summary>
_     _ /// <returns></returns>
_   _   internal DiscoveryRequest Clone() {
   _        return new DiscoveryRequest(this);
      _ }

_   _ __/// <summary>
    _ _ /// Add hosta address as fake address_range
_       /// </summary>
   ___  ///_<param_name="ranges"></param>
     ___///_<returns></returns>
_     _ public IEnumerable<AddressRange> AddLocalHost(IEnumerable<AddressRange> ranges) {
 __    _ __ if (Host.IsContainer) {
_   _          _try_{
 ____   _           var addresses = Dns.GetHostAddresses("host.docker