root / trunk / Pithos.ShellExtensions / FileContext.cs @ aba9e6d9
History | View | Annotate | Download (2.3 kB)
1 |
// <copyright file="IoC.cs" company="GRNet"> |
---|---|
2 |
// This project is open source. Released under the XYZ license |
3 |
// </copyright> |
4 |
|
5 |
using System.Linq; |
6 |
using Microsoft.Win32; |
7 |
|
8 |
namespace Pithos.ShellExtensions |
9 |
{ |
10 |
using System; |
11 |
using Pithos.Interfaces; |
12 |
using System.ComponentModel.Composition; |
13 |
using System.Diagnostics; |
14 |
using System.IO; |
15 |
|
16 |
[Export] |
17 |
public class FileContext |
18 |
{ |
19 |
[Import] |
20 |
public IPithosSettings Settings { get; set; } |
21 |
|
22 |
[Import] |
23 |
public IStatusChecker StatusChecker { get; set; } |
24 |
|
25 |
public string PithosPath { get { return Settings.PithosPath.ToLower(); } } |
26 |
|
27 |
public FileContext() |
28 |
{ |
29 |
} |
30 |
|
31 |
public bool IsManaged |
32 |
{ |
33 |
get |
34 |
{ |
35 |
|
36 |
var accountPath=(from account in Settings.Accounts |
37 |
where !String.IsNullOrWhiteSpace(account.RootPath) && CurrentFile.StartsWith(account.RootPath, StringComparison.InvariantCultureIgnoreCase) |
38 |
select account.RootPath).FirstOrDefault(); |
39 |
Debug.WriteLine(String.Format("Account path is {0}\r\n Current Path is {1}", accountPath, CurrentFile), LogCategories.Shell); |
40 |
return !String.IsNullOrWhiteSpace(accountPath); |
41 |
} |
42 |
} |
43 |
|
44 |
public bool IsFolder { get; set; } |
45 |
private string _currentFolder; |
46 |
public string CurrentFolder |
47 |
{ |
48 |
get { return _currentFolder; } |
49 |
set |
50 |
{ |
51 |
_currentFolder = value.ToLower(); |
52 |
IsFolder = true; |
53 |
_currentFile = _currentFolder; |
54 |
} |
55 |
} |
56 |
|
57 |
private string _currentFile; |
58 |
public string CurrentFile |
59 |
{ |
60 |
get { return _currentFile; } |
61 |
set |
62 |
{ |
63 |
_currentFile = value.ToLower(); |
64 |
Debug.WriteLine(String.Format("File is {0}", _currentFile), LogCategories.Shell); |
65 |
if (Directory.Exists(_currentFile)) |
66 |
{ |
67 |
_currentFolder = _currentFile; |
68 |
IsFolder = true; |
69 |
} |
70 |
else |
71 |
{ |
72 |
_currentFolder = Path.GetDirectoryName(_currentFile); |
73 |
IsFolder = false; |
74 |
} |
75 |
|
76 |
} |
77 |
} |
78 |
} |
79 |
|
80 |
} |