file360

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 using System;
using System.Collections.ObjectModel;
using System.IO;
using System.IO.IsolatedStorage;
using System.Threading.Tasks;
using System.Windows;
using Windows.Storage;
using System.Text;
using Windows.Storage.Streams;
using System.Windows.Threading;

namespace WinPhoneFtp.FtpService
{
    public sealed class Logger
    {
        private static Logger s_Logger = null;
        public static Logger GetDefault(Dispatcher UIDispatcher)
        {
            if (s_Logger == null)
            {
                s_Logger = new Logger(UIDispatcher);
            }
            return s_Logger;
        }

        private Dispatcher UIDispatcher = null;

        private Logger(Dispatcher UIDispatcher)
        {
            Logs = new ObservableCollection<String>();
            this.UIDispatcher = UIDispatcher != null ? UIDispatcher : Deployment.Current.Dispatcher;
        }

        public ObservableCollection<String> Logs
        {
            get;
            private set;
        }

        public void AddLog(String LogInfo)
        {
            UIDispatcher.BeginInvoke(() =>
            {
                System.Diagnostics.Debug.WriteLine(LogInfo);
                Logs.Add(LogInfo);
            });
        }
    }
}