//uploading.
public class NetworkGate:IDisposable
{
+ public string FilePath { get; private set; }
+ public NetworkOperation Operation { get; private set; }
+
+ [ContractInvariantMethod]
+ private void Invariants()
+ {
+ Contract.Invariant(!String.IsNullOrWhiteSpace(FilePath));
+ Contract.Invariant(Path.IsPathRooted(FilePath));
+ }
+
//The state of each file is stored in a thread-safe dictionary
static readonly ConcurrentDictionary<string, NetworkOperation> NetworkState = new ConcurrentDictionary<string, NetworkOperation>();
- public string FilePath { get; private set; }
- public NetworkOperation Operation { get; private set; }
+
+
private NetworkGate(string path,NetworkOperation operation)
{
if (String.IsNullOrWhiteSpace(path))
throw new ArgumentNullException("path");
+ if (!Path.IsPathRooted(path))
+ throw new ArgumentException("path must be rooted","path");
Contract.EndContractBlock();
Operation = operation;
- FilePath = path.ToLower();
+ FilePath = path.ToLower();
//Skip dummy operations (those with Operation == None)
if (Operation != NetworkOperation.None)