private static void Main(string[] args) { var basePath = AppDomain.CurrentDomain.BaseDirectory; settingsPath = ConfigurationManager.AppSettings["settingsFile"]; statusesPath = ConfigurationManager.AppSettings["statusesFile"]; outputPath = ConfigurationManager.AppSettings["outputPath"]; if (string.IsNullOrWhiteSpace(settingsPath) || !File.Exists(settingsPath)) { return; } if (string.IsNullOrWhiteSpace(statusesPath)) { statusesPath = Path.Combine(basePath, "statuses.txt"); } if (string.IsNullOrWhiteSpace(outputPath)) { outputPath = Path.Combine(basePath, "out"); } if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } var container = new UnityContainer(); container.AddNewExtension <Interception>(); container.RegisterType <IDocumentListener, DocumentListener>(new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior <LoggingInterceptionBehavior>()); container.RegisterType <IListener <StatusDTO>, StatusListener>(new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior <LoggingInterceptionBehavior>()); container.RegisterType <IPublisher <SettingsDTO>, SettingsPublisher>(new Interceptor <InterfaceInterceptor>(), new InterceptionBehavior <LoggingInterceptionBehavior>()); documentListener = container.Resolve <IDocumentListener>(new ParameterOverride("outputPath", outputPath)); statusListener = container.Resolve <IListener <StatusDTO> >(); settingsPublisher = container.Resolve <IPublisher <SettingsDTO> >(); using (documentListener) using (statusListener) { documentListener.Start(); statusListener.Start(); statusListener.Received += StatusListener_Received; watcher.Path = Path.GetDirectoryName(settingsPath); watcher.Filter = "*.json"; watcher.Changed += Watcher_Changed; watcher.EnableRaisingEvents = true; Console.WriteLine("Press [enter] to exit..."); Console.ReadLine(); watcher.EnableRaisingEvents = false; } }
public Document(string filePath, IDocumentListener listener) { // set name from file path _name = Path.GetFileNameWithoutExtension(filePath); if (null != listener) { // add listener AddListener(listener); // notify listener of document creation listener.OnNewDocument(this); } // load file Load(filePath); // rechange name to match filePath _name = Path.GetFileNameWithoutExtension(filePath); }
public DocumentSB(string name, string description, string author, IDocumentListener listener) : base(name, description, author, DateTime.Now, listener) { _dirty = false; }
public DocumentSB(string filePath, IDocumentListener listener) : base(filePath, listener) { _filePath = filePath; _dirty = false; }
public void AddListener(IDocumentListener listener) { _listeners.Add(listener); }
public Document(string name, string description, string author, DateTime dateCreated, IDocumentListener listener) { _name = name; _description = description; _author = author; _dateCreated = dateCreated; if (null != listener) { // add listener AddListener(listener); // notify listener of document creation listener.OnNewDocument(this); } }