All files
[pithos-ms-client] / trunk / Pithos.ShellExtensions.Test / TestStatusChecker.cs
1 using System;
2 using System.ComponentModel.Composition;
3 using System.Diagnostics;
4 using System.Diagnostics.Contracts;
5 using System.IO;
6 using Pithos.Interfaces;
7
8 namespace Pithos.ShellExtensions
9 {
10     [Export(typeof(IStatusChecker))]
11     public class TestStatusChecker:IStatusChecker
12     {
13         [Import]
14         private IPithosSettings Settings;
15
16         private readonly string[] _states = {"Normal", "Modified", "Conflict","Synch"};
17
18         public string GetFileStatus(string path)
19         {
20             Contract.Requires(!String.IsNullOrWhiteSpace(path));
21             var pithosPath = Settings.PithosPath;
22             if (path.StartsWith(pithosPath,true,null))
23             {
24                 var fileName = Path.GetFileName(path);
25                 if (String.IsNullOrWhiteSpace(fileName))
26                     return _states[0];
27
28                 var status = Char.ConvertToUtf32(fileName, 0)%4;
29                 return _states[status];
30             }
31             return String.Empty;
32         }
33     }
34 }