Added log4net for client profile
[pithos-ms-client] / trunk / Pithos.Core / NetworkGate.cs
index 906ce5d..5fd4c18 100644 (file)
@@ -17,6 +17,16 @@ namespace Pithos.Core
     //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>();
 
@@ -74,17 +84,19 @@ namespace Pithos.Core
 
 
 
-        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)