Swapper.NET Logo

Source Code Interfaces ~ IFileSource.cs


using System;
using System.Collections.Specialized;
using System.Xml;
using RevolutionaryStuff.JBT;
using RevolutionaryStuff.P2P.Basics;

namespace RevolutionaryStuff.P2P.Basics
{
	public interface IFileSource : IFieldApplicator
	{
		/// 
		/// The name of the file
		/// 
		string Name {get;}
		/// 
		/// The size of the file
		/// 
		long Size {get;}
		/// 
		/// The file server on which this resides
		/// 
		IFileServer FileServer {get;}
		/// 
		/// A list of urls to get the file.  
		/// This must always have at least 1 entry.  
		/// When there are multiple entries, they are listed in the order in which they should be used
		/// 
		string[] Urls {get;}
		/// 
		/// List of urns
		/// 
		StringCollection Urns { get; }
		/// 
		/// The Primary URN for this file source
		/// 
		string PrimaryUrn { get; }
		/// 
		/// Array of child sources in the group.  
		/// Will probably be zero length
		/// 
		IFileSource[] ConstituentSources{get;}

		IFileSourceSerializer GetSerializer();
	}

	public enum FileSourceState
	{
		/// 
		/// This item has not yet been initialized
		/// 
		NotInitialized,
		/// 
		/// This is an incomplete file source.  We do not have all the data.
		/// 
		Incomplete,
		/// 
		/// This is a full source
		/// 
		Complete,
		/// 
		/// This item has been deleted
		/// 
		Deleted
	}

	public interface IFileSourceSerializer
	{
		void Serialize(IFileSource fs, XmlWriter w);
		void Deserialize(IFileSource fs, XmlReader r);
	}

	public interface IFileSourceFactory
	{
		IFileSource Create(string factorySelector);
	}

	public class FileSourceEventArgs : EventArgs
	{
		public readonly IFileSource[] FileSources;
		public FileSourceEventArgs(params IFileSource[] fileSources)
		{
			this.FileSources = fileSources;
		}
	}

	public delegate void FileSourceEventHandler(object sender, FileSourceEventArgs args);
}