//--------------------------------------------------------------------------
        //
        //	Methods
        //
        //--------------------------------------------------------------------------

        #region Initialize
        /// <summary>
        /// monitor the log file for changes, set up the initial read
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="siteFileWatcherService"></param>
        public void Initialize(string logDirectory, ISiteFileWatcherService siteFileWatcherService, ITheme theme)
        {
            _logDirectory = new DirectoryInfo(logDirectory);
            _siteFileWatcherService = siteFileWatcherService;
                                    
            _siteFileWatcherService.RegisterForSiteNotifications(WatcherChangeTypes.Created | WatcherChangeTypes.Changed, new FileSystemEventHandler(FileSystemEvent), null);

            //outy.Foreground = theme.DefaultFormat.ForeColor;
            //outy.Background = theme.DefaultFormat.BackColor;
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------
        //
        //	Methods
        //
        //--------------------------------------------------------------------------

        #region Initialize
        /// <summary>
        /// monitor the log file for changes, set up the initial read
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="siteFileWatcherService"></param>
        public void Initialize(string logDirectory, ISiteFileWatcherService siteFileWatcherService, ITheme theme)
        {
            _logDirectory           = new DirectoryInfo(logDirectory);
            _siteFileWatcherService = siteFileWatcherService;

            _siteFileWatcherService.RegisterForSiteNotifications(WatcherChangeTypes.Created | WatcherChangeTypes.Changed, new FileSystemEventHandler(FileSystemEvent), null);

            //outy.Foreground = theme.DefaultFormat.ForeColor;
            //outy.Background = theme.DefaultFormat.BackColor;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// monitor the log file for changes, set up the initial read
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="siteFileWatcherService"></param>
        public void Initialize(string filePath, ISiteFileWatcherService siteFileWatcherService, ITheme theme)
        {
            _filePath = Path.GetFullPath(filePath);
            _siteFileWatcherService = siteFileWatcherService;

            if (File.Exists(_filePath))
                this.PerformInitialRead();

            _siteFileWatcherService.RegisterForSiteNotifications(WatcherChangeTypes.All, new FileSystemEventHandler(FileSystemEvent), null);

            outy.Foreground = theme.DefaultFormat.ForeColor;
            outy.Background = theme.DefaultFormat.BackColor;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// set up the file watcher for detecting changes
        /// </summary>
        protected void InitSite()
        {
            if (_host != null && _host.WebSite != null && !String.IsNullOrEmpty(_host.WebSite.Path))
            {
                prefUtility = new PrefUtility()
                {
                    ExtensionName   = "OrangeBits",
                    SitePath        = _host.WebSite.Path,
                    SitePreferences = _host.WebSite.SitePreferences
                };

                // by default, do not do anything to node_modules
                var path  = Path.Combine(_host.WebSite.Path, "node_modules");
                var isSet = prefUtility.PathHasValue(path);
                if (!isSet)
                {
                    var             props = typeof(OptionViewModel).GetProperties().Where(x => Attribute.IsDefined(x, typeof(DefaultValueAttribute)));
                    OptionViewModel vm    = new OptionViewModel()
                    {
                        Paths = new string[] { path }
                    };

                    foreach (var prop in props)
                    {
                        if (prop.PropertyType == typeof(bool?))
                        {
                            prop.SetValue(vm, false, null);
                        }
                    }
                    prefUtility.SaveOptions(vm);
                }


                _siteFileWatcher.RegisterForSiteNotifications(WatcherChangeTypes.Changed | WatcherChangeTypes.Created, new FileSystemEventHandler(SourceFileChanged), null);
            }
            else
            {
                _siteFileWatcher.DeregisterForSiteNotifications(WatcherChangeTypes.Changed | WatcherChangeTypes.Created, new FileSystemEventHandler(SourceFileChanged), null);
            }
        }