Exemplo n.º 1
0
        public T Remove <T>(Func <T, bool> keyRetrievalFunc) where T : class
        {
            var container = _cache.FirstOrDefault(x => x.Key == typeof(T));

            if (container.Value == null)
            {
                return(null);
            }

            CachedEntity val    = null;
            T            valObj = null;

            foreach (var o in container.Value)
            {
                if (o.CachedObject is T tmp)
                {
                    if (keyRetrievalFunc(tmp))
                    {
                        valObj = tmp;
                        val    = o;
                        break;
                    }
                }
            }

            if (val != null)
            {
                container.Value.TryRemove(val);
            }

            return(valObj);
        }
Exemplo n.º 2
0
        public void GetAnagramsFromCache_ShouldReturnEmptyIfNothingIsPassed()
        {
            RequestedWord = "";
            ExpectedList  = new List <string>()
            {
            };


            var firstSample = new CachedEntity()
            {
            };
            var secondSample = new CachedEntity()
            {
            };

            IList <CachedEntity> returnedFromCache = new List <CachedEntity>()
            {
                firstSample,
                secondSample
            };

            _cacheRepository.GetCacheListByRequestWord(RequestedWord).Returns(returnedFromCache);

            //////////////////////////////////
            //////////////////////////////////

            var result = _cacheService.GetAnagramsFromCache(RequestedWord);

            result.ShouldBeEmpty();

            _cacheRepository.DidNotReceive().GetCacheListByRequestWord(RequestedWord);
        }
Exemplo n.º 3
0
        public async Task <NetflixAccount> GetAsync(CancellationToken cancellationToken = default)
        {
            await _lock.WaitAsync(cancellationToken).ConfigureAwait(false);

            try
            {
                CachingOptions cachingOptions = _cachingOptions.Get(CacheOptionName);
                if (cachingOptions.Enabled && _cachedAccount != null && !_cachedAccount.IsExpired)
                {
                    _log.LogTrace("Netflix account found in cache");
                    return(_cachedAccount);
                }

                _log.LogDebug("Retrieving Netflix account from database");
                NetflixAccount result = await _netflixAccountsCollection.Find(_ => true).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);

                if (result == null)
                {
                    _log.LogTrace("Netflix account not found, creating default");
                    result = new NetflixAccount();
                }

                if (cachingOptions.Enabled)
                {
                    _cachedAccount = new CachedEntity <string, NetflixAccount>(result.Login, result, cachingOptions.Lifetime);
                }
                return(result);
            }
            finally
            {
                _lock.Release();
            }
        }
Exemplo n.º 4
0
        public int Add(CachedEntity cacheModel)
        {
            _db.CachedWords.Add(cacheModel);
            _db.SaveChanges();

            return(cacheModel.Id);
        }
Exemplo n.º 5
0
 public ValueTask set_lastReturnValue(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "lastReturnValue",
                value
                ));
 }
Exemplo n.º 6
0
 public ValueTask set_attachedElement(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "attachedElement",
                value
                ));
 }
Exemplo n.º 7
0
 public ValueTask set_userInfo(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "userInfo",
                value
                ));
 }
Exemplo n.º 8
0
 public ValueTask set_parallelShaderCompile(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "parallelShaderCompile",
                value
                ));
 }
Exemplo n.º 9
0
 public static ValueTask set_RegisteredExternalClasses(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                "BABYLON",
                "Tools.RegisteredExternalClasses",
                value
                ));
 }
 public static ValueTask set_IncludesShadersStore(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                "BABYLON",
                "Effect.IncludesShadersStore",
                value
                ));
 }
Exemplo n.º 11
0
 public void AddOrReplace(TKey key, TEntity entity, TimeSpan lifetime)
 {
     lock (_cachedEntities)
     {
         _cachedEntities[key] = new CachedEntity <TKey, TEntity>(key, entity, lifetime);
         this.ClearExpiredInternal();
     }
 }
 public ValueTask set_DEBUGCANVASPOS(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "DEBUGCANVASPOS",
                value
                ));
 }
Exemplo n.º 13
0
 public ValueTask set_vrDisplay(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "vrDisplay",
                value
                ));
 }
Exemplo n.º 14
0
 public static ValueTask set_Triggers(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                "BABYLON",
                "AbstractActionManager.Triggers",
                value
                ));
 }
Exemplo n.º 15
0
 public ValueTask set_CANNON(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "CANNON",
                value
                ));
 }
Exemplo n.º 16
0
 public ValueTask set_triggerOptions(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "triggerOptions",
                value
                ));
 }
Exemplo n.º 17
0
 public ValueTask set_DracoDecoderModule(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "DracoDecoderModule",
                value
                ));
 }
Exemplo n.º 18
0
 public ValueTask set_additionalData(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "additionalData",
                value
                ));
 }
Exemplo n.º 19
0
 protected override bool IsEntityExpired(CachedEntity <UserData> entity)
 {
     if (_expirationTime < TimeSpan.Zero)
     {
         return(false);
     }
     return(entity.CachingTimeUtc + _expirationTime < DateTime.UtcNow);
 }
Exemplo n.º 20
0
 public static ValueTask set_CustomRequestHeaders(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                "BABYLON",
                "Tools.CustomRequestHeaders",
                value
                ));
 }
Exemplo n.º 21
0
 public ValueTask set_previousWorldMatrices(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "previousWorldMatrices",
                value
                ));
 }
Exemplo n.º 22
0
 public ValueTask set_oculusMultiview(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "oculusMultiview",
                value
                ));
 }
Exemplo n.º 23
0
 public ValueTask set_source(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "source",
                value
                ));
 }
Exemplo n.º 24
0
 public ValueTask set_checks(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "checks",
                value
                ));
 }
Exemplo n.º 25
0
 public ValueTask set_metadata(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "metadata",
                value
                ));
 }
Exemplo n.º 26
0
 public ValueTask set_defineNames(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "defineNames",
                value
                ));
 }
Exemplo n.º 27
0
 public ValueTask set_reservedDataStore(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "reservedDataStore",
                value
                ));
 }
 public ValueTask set_extensions(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "extensions",
                value
                ));
 }
 public ValueTask set_lockedTarget(CachedEntity value)
 {
     return(EventHorizonBlazorInterop.Set(
                this.___guid,
                "lockedTarget",
                value
                ));
 }
 public async ValueTask forceCompilationAsync(CachedEntity options = null)
 {
     await EventHorizonBlazorInterop.Task <CachedEntity>(
         new object[]
     {
         new string[] { this.___guid, "forceCompilationAsync" }, options
     }
         );
 }
Exemplo n.º 31
0
        /// <summary>
        /// Gets the incidents.
        /// </summary>
        /// <param name="refreshData">if set to <c>true</c> [refresh data].</param>
        /// <returns></returns>
        public IObservable<Incident> GetIncidents(bool refreshData)
        {
            var cachedIncidents = new CachedEntity<List<Incident>>("Services.Incidents");

            return new AnonymousObservable<Incident>(observer =>
            {
                if (refreshData || !cachedIncidents.Value.Any() || cachedIncidents.CachedDateTime <= DateTime.Now.AddMinutes(-10))
                {
                    IObservable<string> observable = ObservableHelper.TextFromUri(new Uri(HoustonTranstarUri.IncidentsUri));

                    var svc = observable.Subscribe(result =>
                    {
                        XElement xmlDoc = XElement.Parse(result);

                        string title = (string)xmlDoc.Element("channel").Element("title");

                        var incidents = from item in xmlDoc.Element("channel").Elements("item")
                                        select new Incident
                                        {
                                            Title = (string)item.Element("title"),
                                            PublishedDate = item.Element("pubDate") != null ? ((DateTime)item.Element("pubDate")).ToLocalTime() : DateTime.MinValue
                                        };

                        cachedIncidents.Value = incidents.ToList();
                        cachedIncidents.Cache();

                        incidents.ToList().ForEach(i => observer.OnNext(i));
                        observer.OnCompleted();
                    }, ex =>
                    {
                        observer.OnError(new Exception("Unable to retrieve traffic data.", ex));
                    });
                }
                else
                {
                    cachedIncidents.Value.ToList().ForEach(i => observer.OnNext(i));
                    observer.OnCompleted();
                }

                return Disposable.Empty;
            });
        }
Exemplo n.º 32
0
        /// <summary>
        /// Gets the cameras.
        /// </summary>
        /// <param name="cameraType">Type of the camera.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public IObservable<Camera> GetCameras(CameraType cameraType, string name)
        {
            var cachedCameras = new CachedEntity<List<Camera>>(string.Format("Services.Camera.{0}.{1}", cameraType, name));

            return new AnonymousObservable<Camera>(observer =>
            {
                if (!cachedCameras.Value.Any() || !cachedCameras.CachedDateTime.HasValue || cachedCameras.CachedDateTime.Value <= DateTime.Now.AddDays(-1))
                {
                    Uri cameraListUri = null;

                    if (cameraType == CameraType.Regional)
                    {
                        cameraListUri = new Uri(string.Format("{0}?roadway={1}", DfwTranstarUri.CamerasRegionalUri, name.Replace(' ', '_')));
                    }
                    else
                    {
                        cameraListUri = new Uri(string.Format("{0}?list={1}&roadway={2}", DfwTranstarUri.CamerasUri, cameraType.ToString().ToLower(), name.Replace(' ', '_')));
                    }

                    IObservable<string> observable = ObservableHelper.TextFromUri(cameraListUri);

                    var svc = observable.Subscribe(result =>
                    {
                        int tableStart = result.IndexOf("<table id=\"ListTable\"");
                        int tableEnd = result.IndexOf("</table>", tableStart);

                        XElement xmlDoc = XElement.Parse(result.Substring(tableStart, (tableEnd + 8) - tableStart));

                        var cameras = from item in xmlDoc.Element("tr").Element("td").Element("ul").Elements("li")
                                      select new Camera
                                      {
                                          ID = this.GetCameraID(cameraType, item.Element("a").Attribute("href").Value),
                                          Name = item.Value,
                                          EnableThumbnails = ProfileCommon.UserSettings.ShowCameraThumbnails,
                                          ImageUri = cameraType == CameraType.Regional ?
                                              string.Format(DfwTranstarUri.CameraDetailRegionalUri, name.ToLower()
                                              .Replace(" north", "")
                                              .Replace(" south", "")
                                              .Replace(" east", "")
                                              .Replace(" west", ""),
                                              this.GetCameraID(cameraType, item.Element("a").Attribute("href").Value)) :
                                              string.Format(DfwTranstarUri.CameraDetailUri, this.GetCameraID(cameraType, item.Element("a").Attribute("href").Value))
                                      };

                        cachedCameras.Value = cameras.ToList();
                        cachedCameras.Cache();

                        cachedCameras.Value.ToList().ForEach(c => observer.OnNext(c));
                        observer.OnCompleted();
                    },
                    ex =>
                    {
                        observer.OnError(new Exception("Unable to retrieve traffic data.", ex));
                    });
                }
                else
                {
                    cachedCameras.Value.ToList().ForEach(c => observer.OnNext(c));
                    observer.OnCompleted();
                }

                return Disposable.Empty;
            });
        }
Exemplo n.º 33
0
        /// <summary>
        /// Gets the travel time roadways.
        /// </summary>
        /// <param name="refresh">if set to <c>true</c> [refresh].</param>
        /// <returns></returns>
        public IObservable<Roadway> GetTravelTimeRoadways()
        {
            var cachedRoadways = new CachedEntity<List<Roadway>>("Services.TravelTimeRoadways");

            return new AnonymousObservable<Roadway>(observer =>
            {
                if (!cachedRoadways.Value.Any() || !cachedRoadways.CachedDateTime.HasValue || cachedRoadways.CachedDateTime.Value <= DateTime.Now.AddDays(-1))
                {
                    IObservable<string> observable = ObservableHelper.TextFromUri(new Uri(DfwTranstarUri.TravelTimeUri));

                    observable.Subscribe(result =>
                    {
                        IEnumerable<Roadway> roadways = null;

                        if (result != null)
                        {
                            int tableStart = result.IndexOf("<span id=\"RoadwayList\"");
                            int tableEnd = result.IndexOf("</span>", tableStart);

                            XElement xmlDoc = XElement.Parse(result.Substring(tableStart, (tableEnd + 7) - tableStart));

                            roadways = from item in xmlDoc.Elements("a")
                                       select new Roadway
                                       {
                                           ID = item.Attribute("href").Value,
                                           Name = item.Value,
                                           IconUri = this.GetRoadwayIconUri(item.Value)
                                       };
                        }

                        cachedRoadways.Value = roadways.ToList();
                        cachedRoadways.Value.ToList().ForEach(r => observer.OnNext(r));
                        observer.OnCompleted();
                    }, ex =>
                    {
                        observer.OnError(new Exception("Unable to retrieve traffic data.", ex));
                    });
                }
                else
                {
                    cachedRoadways.Value.ToList().ForEach(r => observer.OnNext(r));
                    observer.OnCompleted();
                }

                return Disposable.Empty;
            });
        }
Exemplo n.º 34
0
        /// <summary>
        /// Gets the roadway cameras.
        /// </summary>
        /// <param name="cameraType">Type of the camera.</param>
        /// <returns></returns>
        public IObservable<Roadway> GetRoadwayCameras(CameraType cameraType)
        {
            var cachedRoadways = new CachedEntity<List<Roadway>>("Services.RoadwayCameras." + cameraType.ToString());

            return new AnonymousObservable<Roadway>(observer =>
            {
                if (!cachedRoadways.Value.Any() || cachedRoadways.CachedDateTime <= DateTime.Now.AddDays(-1))
                {
                    Uri uri = null;

                    switch (cameraType)
                    {
                        case CameraType.Freeway:
                            uri = new Uri(DfwTranstarUri.CamerasUri);
                            break;

                        case CameraType.Street:
                            uri = new Uri(DfwTranstarUri.CamerasUri + "?list=street");
                            break;

                        case CameraType.Regional:
                            uri = new Uri(DfwTranstarUri.CamerasRegionalUri);
                            break;
                    }

                    IObservable<string> observable = ObservableHelper.TextFromUri(uri);

                    var svc = observable.Subscribe(result =>
                    {
                        int tableStart = result.IndexOf("<table id=\"ListTable\"");
                        int tableEnd = result.IndexOf("</table>", tableStart);

                        XElement xmlDoc = XElement.Parse(result.Substring(tableStart, (tableEnd + 8) - tableStart));

                        var roadways = from item in xmlDoc.Element("tr").Element("td").Element("ul").Elements("li")
                                       select new Roadway
                                       {
                                           Name = item.Value,
                                           IconUri = cameraType == CameraType.Freeway ?
                                                this.GetRoadwayIconUri(item.Value) : "/Resources/Images/empty_svg_small.png"
                                       };

                        cachedRoadways.Value = roadways.ToList();
                        cachedRoadways.Cache();

                        cachedRoadways.Value.ToList().ForEach(r => observer.OnNext(r));
                        observer.OnCompleted();
                    }, ex =>
                    {
                        observer.OnError(new Exception("Unable to retrieve traffic data.", ex));
                    });
                }
                else
                {
                    cachedRoadways.Value.ToList().ForEach(r => observer.OnNext(r));
                    observer.OnCompleted();
                }

                return Disposable.Empty;
            });
        }
Exemplo n.º 35
0
        /// <summary>
        /// Gets the road closures.
        /// </summary>
        /// <param name="refreshData">if set to <c>true</c> [refresh data].</param>
        /// <returns></returns>
        public IObservable<RoadClosure> GetRoadClosures(bool refreshData)
        {
            var cachedRoadClosures = new CachedEntity<RoadClosure>("Services.RoadClosures");

            return new AnonymousObservable<RoadClosure>(observer =>
            {
                if (refreshData || !cachedRoadClosures.CachedDateTime.HasValue || cachedRoadClosures.CachedDateTime.Value <= DateTime.Now.AddMinutes(-15))
                {
                    IObservable<string> observable = ObservableHelper.TextFromUri(new Uri(DfwTranstarUri.BaseUri + "/mobile/roadclosures.aspx"));

                    observable.Subscribe(result =>
                    {
                        RoadClosure roadClosure = new RoadClosure();

                        if (result != null)
                        {
                            int spanStart = result.IndexOf("<span id=\"RCMessage\"");
                            int spanEnd = result.IndexOf("</span>", spanStart);
                            string message = string.Empty;

                            if (spanStart > 0)
                            {
                                message = result.Substring(spanStart + 21, spanEnd - spanStart - 21).Trim()
                                    .Replace("<br/>", "\n")
                                    .Replace("<br />", "\n")
                                    .Replace("</br>", "")
                                    .Replace("<b>", "")
                                    .Replace("</b>", "");
                            }

                            roadClosure.Closure = message;
                        }

                        cachedRoadClosures.Value = roadClosure;
                        cachedRoadClosures.Cache();

                        observer.OnNext(roadClosure);
                        observer.OnCompleted();
                    }, ex =>
                    {
                        observer.OnError(new Exception("Unable to retrieve traffic data.", ex));
                    },
                    () => { });
                }
                else
                {
                    observer.OnNext(cachedRoadClosures.Value);
                    observer.OnCompleted();
                }

                return Disposable.Empty;
            });
        }
Exemplo n.º 36
0
        /// <summary>
        /// Gets the message sign locations.
        /// </summary>
        /// <param name="roadway">The roadway.</param>
        /// <returns></returns>
        public IObservable<Roadway> GetMessageSignLocations(string roadway)
        {
            var key = string.Format("Services.MessageSignRoadways.Location.{0}", roadway.Substring(roadway.IndexOf("roadway=") + 8));
            var cachedRoadways = new CachedEntity<List<Roadway>>(key);

            return new AnonymousObservable<Roadway>(observer =>
            {
                if (!cachedRoadways.Value.Any() || !cachedRoadways.CachedDateTime.HasValue || cachedRoadways.CachedDateTime.Value <= DateTime.Now.AddMinutes(-30))
                {
                    IObservable<string> observable = ObservableHelper.TextFromUri(new Uri(DfwTranstarUri.MessageSignUri + roadway));

                    observable.Subscribe(result =>
                    {
                        IEnumerable<Roadway> roadways = null;

                        if (result != null)
                        {
                            int tableStart = result.IndexOf("<ul id=\"StreetList\"");
                            int tableEnd = result.IndexOf("</ul>", tableStart);

                            XElement xmlDoc = XElement.Parse(result.Substring(tableStart, (tableEnd + 5) - tableStart));

                            roadways = from item in xmlDoc.Descendants("a")
                                       select new Roadway
                                       {
                                           ID = item.Attribute("href").Value,
                                           Name = item.Value
                                       };
                        }

                        cachedRoadways.Value = roadways.ToList();
                        cachedRoadways.Value.ToList().ForEach(r => observer.OnNext(r));
                        observer.OnCompleted();
                    }, ex =>
                    {
                        observer.OnError(new Exception("Unable to retrieve traffic data.", ex));
                    });
                }
                else
                {
                    cachedRoadways.Value.ToList().ForEach(r => observer.OnNext(r));
                    observer.OnCompleted();
                }

                return Disposable.Empty;
            });
        }
Exemplo n.º 37
0
        /// <summary>
        /// Gets the incidents.
        /// </summary>
        /// <param name="refreshData">if set to <c>true</c> [refresh data].</param>
        /// <returns></returns>
        public IObservable<Incident> GetIncidents(bool refreshData)
        {
            var cachedIncidents = new CachedEntity<List<Incident>>("Services.Incidents");

            return new AnonymousObservable<Incident>(observer =>
            {
                if (refreshData || !cachedIncidents.Value.Any() || cachedIncidents.CachedDateTime <= DateTime.Now.AddMinutes(-10))
                {
                    IObservable<string> observable = ObservableHelper.TextFromUri(new Uri(string.Format("{0}?CenterId={1}", DfwTranstarUri.IncidentsUri, TrafficCenter.DalTrans)));

                    var svc = observable.Subscribe(result =>
                    {
                        List<Incident> incidents;
                        int indexStart = result.IndexOf("<span id=\"LabelTime\"");
                        int indexEnd = result.IndexOf("</span>", indexStart);
                        var incidentTime = result.Substring(indexStart + 21, indexEnd - indexStart - 21);

                        indexStart = result.IndexOf("<ul id=\"IncidentList\"");

                        if (indexStart > 0)
                        {
                            indexEnd = result.IndexOf("</ul>", indexStart);

                            XElement xmlDoc = XElement.Parse(result.Substring(indexStart, (indexEnd + 5) - indexStart));

                            incidents = (from item in xmlDoc.Elements("li")
                                        select new Incident
                                        {
                                            Title = item.Value,
                                            PublishedDate = DateTime.Parse(string.Format("{0:d} {1}", DateTime.Today, incidentTime))
                                        }).ToList();
                        }
                        else
                        {
                            incidents = new List<Incident>();
                            incidents.Add(new Incident() { Title = "No incidents found",
                                PublishedDate = DateTime.Parse(string.Format("{0:d} {1}", DateTime.Today, incidentTime)) });
                        }

                        cachedIncidents.Value = incidents.ToList();
                        cachedIncidents.Cache();

                        incidents.ToList().ForEach(i => observer.OnNext(i));
                        observer.OnCompleted();
                    }, ex =>
                    {
                        observer.OnError(new Exception("Unable to retrieve traffic data.", ex));
                    });
                }
                else
                {
                    cachedIncidents.Value.ToList().ForEach(i => observer.OnNext(i));
                    observer.OnCompleted();
                }

                return Disposable.Empty;
            });
        }
Exemplo n.º 38
0
        /// <summary>
        /// Gets the construction closures.
        /// </summary>
        /// <param name="roadway">The roadway.</param>
        /// <returns></returns>
        public IObservable<ConstructionClosure> GetConstructionClosures(string roadway)
        {
            var cachedConstructionClosures = new CachedEntity<ConstructionClosure>("Services.ConstructionClosures." + roadway.Replace(" ", "."));

            return new AnonymousObservable<ConstructionClosure>(observer =>
            {
                if (!cachedConstructionClosures.CachedDateTime.HasValue || cachedConstructionClosures.CachedDateTime.Value <= DateTime.Now.AddDays(-1))
                {
                    IObservable<string> observable = ObservableHelper.TextFromUri(new Uri(string.Format("{0}?roadway={1}",
                        DfwTranstarUri.ConstructionClosure, roadway.Replace(" ", "_"))));

                    observable.Subscribe(result =>
                    {
                        ConstructionClosure constructionClosure = new ConstructionClosure() { Roadway = roadway };

                        if (result != null)
                        {
                            int spanStart = result.IndexOf("<span id=\"CurrentConstruction\"");
                            int spanEnd = result.IndexOf("</span>", spanStart);
                            string message = string.Empty;

                            if (spanStart > 0)
                            {
                                message = result.Substring(spanStart + 31, spanEnd - spanStart - 31).Trim()
                                    .Replace("<br/>", "\n")
                                    .Replace("<br />", "\n")
                                    .Replace("</br>", ""); ;
                            }

                            constructionClosure.Message = message;
                        }

                        cachedConstructionClosures.Value = constructionClosure;
                        cachedConstructionClosures.Cache();

                        observer.OnNext(constructionClosure);
                        observer.OnCompleted();
                    }, ex =>
                    {
                        observer.OnError(new Exception("Unable to retrieve traffic data.", ex));
                    },
                    () => { });
                }
                else
                {
                    observer.OnNext(cachedConstructionClosures.Value);
                    observer.OnCompleted();
                }

                return Disposable.Empty;
            });
        }