Exemple #1
0
        public override object StartMonitoringStreamForChanges(string streamName, StreamChangeCallback callback)
        {
            WebConfigurationHostFileChange change;

            lock (this)
            {
                change = new WebConfigurationHostFileChange(callback);
                ArrayList list = (ArrayList)this.FileChangeCallbacks[streamName];
                if (list == null)
                {
                    list = new ArrayList(1);
                    this.FileChangeCallbacks.Add(streamName, list);
                }
                list.Add(change);
            }
            HttpRuntime.FileChangesMonitor.StartMonitoringFile(streamName, new FileChangeEventHandler(change.OnFileChanged));
            return(change);
        }
        public override object StartMonitoringStreamForChanges(string streamName, StreamChangeCallback callback)
        {
            WebConfigurationHostFileChange wrapper;

            // Note: in theory it's possible for multiple config records to monitor the same stream.
            // That's why we use the arraylist to store the callbacks.
            lock (this) {
                wrapper = new WebConfigurationHostFileChange(callback);
                ArrayList list = (ArrayList)FileChangeCallbacks[streamName];
                if (list == null)
                {
                    list = new ArrayList(1);
                    FileChangeCallbacks.Add(streamName, list);
                }

                list.Add(wrapper);
            }

            HttpRuntime.FileChangesMonitor.StartMonitoringFile(
                streamName, new FileChangeEventHandler(wrapper.OnFileChanged));

            return(wrapper);
        }
        public override void StopMonitoringStreamForChanges(string streamName, StreamChangeCallback callback)
        {
            WebConfigurationHostFileChange wrapper = null;

            lock (this) {
                ArrayList list = (ArrayList)FileChangeCallbacks[streamName];
                for (int i = 0; i < list.Count; i++)
                {
                    WebConfigurationHostFileChange item = (WebConfigurationHostFileChange)list[i];
                    if (object.ReferenceEquals(item.Callback, callback))
                    {
                        wrapper = item;
                        list.RemoveAt(i);
                        if (list.Count == 0)
                        {
                            FileChangeCallbacks.Remove(streamName);
                        }
                        break;
                    }
                }
            }

            HttpRuntime.FileChangesMonitor.StopMonitoringFile(streamName, wrapper);
        }
        public override object StartMonitoringStreamForChanges(string streamName, StreamChangeCallback callback) {
            WebConfigurationHostFileChange wrapper;

            // Note: in theory it's possible for multiple config records to monitor the same stream.
            // That's why we use the arraylist to store the callbacks.
            lock (this) {
                wrapper = new WebConfigurationHostFileChange(callback);
                ArrayList list = (ArrayList) FileChangeCallbacks[streamName];
                if (list == null) {
                    list = new ArrayList(1);
                    FileChangeCallbacks.Add(streamName, list);
                }

                list.Add(wrapper);
            }

            HttpRuntime.FileChangesMonitor.StartMonitoringFile(
                    streamName, new FileChangeEventHandler(wrapper.OnFileChanged));

            return wrapper;
        }
 public override object StartMonitoringStreamForChanges(string streamName, StreamChangeCallback callback)
 {
     WebConfigurationHostFileChange change;
     lock (this)
     {
         change = new WebConfigurationHostFileChange(callback);
         ArrayList list = (ArrayList) this.FileChangeCallbacks[streamName];
         if (list == null)
         {
             list = new ArrayList(1);
             this.FileChangeCallbacks.Add(streamName, list);
         }
         list.Add(change);
     }
     HttpRuntime.FileChangesMonitor.StartMonitoringFile(streamName, new FileChangeEventHandler(change.OnFileChanged));
     return change;
 }