Ejemplo n.º 1
0
		void ProcessFile(object sender, ScanEventArgs e)
		{
			if ( (events_ != null) && (events_.ProcessFile != null) ) {
				events_.ProcessFile(sender, e);
			}
			
			if ( e.ContinueRunning ) {
                try {
                    // The open below is equivalent to OpenRead which gaurantees that if opened the 
                    // file will not be changed by subsequent openers, but precludes opening in some cases
                    // were it could succeed.
                    using (var stream = File.Open(e.Name, FileMode.Open, FileAccess.Read, FileShare.Read)) {
                        var entry = entryFactory_.MakeFileEntry(e.Name);
                        outputStream_.PutNextEntry(entry);
                        AddFileContents(e.Name, stream);
                    }
                }
                catch(Exception ex) {
                    if (events_ != null) {
                        continueRunning_ = events_.OnFileFailure(e.Name, ex);
                    }
                    else {
                        continueRunning_ = false;
                        throw;
                    }
                }
			}
		}
		/// <summary>
		/// Raise the complete file event
		/// </summary>
		/// <param name="file">The file name</param>
		void OnCompleteFile(string file)
		{
			var handler = CompletedFile;

			if (handler != null)
			{
				var args = new ScanEventArgs(file);
				handler(this, args);
				alive_ = args.ContinueRunning;
			}
		}
Ejemplo n.º 3
0
		/// <summary>
        /// Fires the <see cref="CompletedFile"/> delegate
		/// </summary>
		/// <param name="file">The file whose processing has been completed.</param>
		/// <returns>A boolean indicating if execution should continue or not.</returns>
		public bool OnCompletedFile(string file)
		{
			var result = true;
			var handler = CompletedFile;
			if ( handler != null ) {
				var args = new ScanEventArgs(file);
				handler(this, args);
				result = args.ContinueRunning;
			}
			return result;
		}