/// <summary> /// Check if the given resource is being observed or not /// </summary> /// <param name="observableResourceURL">A URL indicating an observable resource</param> /// <returns>bool</returns> public bool IsResourceBeingObserved(string observableResourceURL) { if (observableResourceURL == null || observableResourceURL.Trim().Length == 0) { throw new ArgumentNullException("Observable resource cannot be NULL or an empty string"); } if (!AbstractURIUtils.IsValidFullUri(observableResourceURL)) { throw new ArgumentException("URL does not seem right. Must be a fully-qualified URL"); } bool isResourceObserved = false; this._observableListSync.WaitOne(); foreach (string key in this._observers.Keys) { if (key == observableResourceURL.Trim().ToLower()) { isResourceObserved = true; break; } } this._observableListSync.Set(); return(isResourceObserved); }
/// <summary> /// Add an observable resource to the list /// </summary> /// <param name="observableResourceURL">A fully-qualified URL indicating an observable resource</param> public void AddObservableResource(string observableResourceURL) { if (observableResourceURL == null || observableResourceURL.Trim().Length == 0) { throw new ArgumentNullException("Observable resource cannot be NULL or an empty string"); } if (!AbstractURIUtils.IsValidFullUri(observableResourceURL)) { throw new ArgumentException("URL does not seem right. Must be a fully-qualified URL"); } this._observableListSync.WaitOne(); if (!this._observers.Contains(observableResourceURL.Trim().ToLower())) { this._observers.Add(observableResourceURL.Trim().ToLower(), new ArrayList()); } this._observableListSync.Set(); }