Added hammock project to debug streaming issues
[pithos-ms-client] / trunk / Pithos.ShellExtensions / FileContext.cs
1 // <copyright file="IoC.cs" company="GRNet">
2 // This project is open source. Released under the XYZ license
3 // </copyright>
4
5 using Microsoft.Win32;
6
7 namespace Pithos.ShellExtensions
8 {
9     using System;
10     using Pithos.Interfaces;
11     using System.ComponentModel.Composition;
12     using System.Diagnostics;
13     using System.IO;
14
15     [Export]
16     public class FileContext
17     {
18         [Import]
19         public IPithosSettings Settings { get; set; }
20
21         [Import]
22         public IStatusChecker StatusChecker { get; set; }
23
24         public string PithosPath { get { return Settings.PithosPath.ToLower(); } }
25
26         public FileContext()
27         {
28         }
29
30         public bool IsManaged
31         {
32             get
33             {
34                 Debug.WriteLine( String.Format("Managed path is {0}\r\n Current Path is {1}", PithosPath, CurrentFile),LogCategories.Shell);
35                 return CurrentFolder.StartsWith(PithosPath, true, null);
36             }
37         }
38
39         public bool IsFolder { get; set; }
40         private string _currentFolder;
41         public string CurrentFolder
42         {
43             get { return _currentFolder; }
44             set
45             {
46                 _currentFolder = value.ToLower();
47                 IsFolder = true;
48                 _currentFile = _currentFolder;
49             }
50         }
51
52         private string _currentFile;
53         public string CurrentFile
54         {
55             get { return _currentFile; }
56             set
57             {
58                 _currentFile = value.ToLower();
59                 Debug.WriteLine(String.Format("File is {0}", _currentFile), LogCategories.Shell);
60                 if (Directory.Exists(_currentFile))
61                 {
62                     _currentFolder = _currentFile;
63                     IsFolder = true;
64                 }
65                 else
66                 {
67                     _currentFolder = Path.GetDirectoryName(_currentFile);
68                     IsFolder = false;
69                 }
70
71             }
72         }
73     }
74
75 }