Statistics
| Branch: | Revision:

root / trunk / Pithos.ShellExtensions / ShellStatusChecker.cs @ 5bcf6d70

History | View | Annotate | Download (1.6 kB)

1
// -----------------------------------------------------------------------
2
// <copyright file="ShellStatusChecker.cs" company="Microsoft">
3
// TODO: Update copyright text.
4
// </copyright>
5
// -----------------------------------------------------------------------
6

    
7
using System.ComponentModel.Composition;
8
using System.Diagnostics;
9
using System.ServiceModel;
10
using Pithos.Interfaces;
11

    
12
namespace Pithos.ShellExtensions
13
{
14
    using System;
15
    using System.Collections.Generic;
16
    using System.Linq;
17
    using System.Text;
18

    
19
    /// <summary>
20
    /// TODO: Update summary.
21
    /// </summary>
22
    [Export(typeof(IStatusChecker))]
23
    public class ShellStatusChecker:IStatusChecker
24
    {
25
        [Import]
26
        public IPithosSettings Settings { get; set; }
27

    
28
        public FileOverlayStatus GetFileOverlayStatus(string path)
29
        {
30

    
31
            try
32
            {
33
                var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
34

    
35
                var remoteAddress = new EndpointAddress("net.pipe://localhost/pithos/statuscache");
36
                using (var client = new PithosService.StatusServiceClient(binding, remoteAddress))
37
                {
38
                    var status = client.GetStatus(path);
39
                    return status;
40
                }
41
            }
42
            catch (Exception exc)
43
            {
44
                Trace.TraceError(exc.ToString());
45
                return FileOverlayStatus.NA;
46
            }
47
        }
48

    
49
        //Not Used by the shell extensions
50
        public PithosStatus GetPithosStatus()
51
        {
52
            throw new NotSupportedException();
53
        }
54
    }
55
}