Beispiel #1
0
        private void HandleFileChange(FileSystemEventArgs e)
        {
            if (IsRepositoryFile(e.FullPath))
            {
                RepositoryItemBase item = null;
                switch (e.ChangeType)
                {
                case WatcherChangeTypes.Changed:
                    WaitforFileIsReadable(e.FullPath);
                    // reLoad the object to mem updating fields
                    item = GetItemFromCacheByFileName(e.FullPath);
                    NewRepositorySerializer.ReloadObjectFromFile(item);
                    item.RefreshSourceControlStatus();
                    break;

                case WatcherChangeTypes.Deleted:
                    //remove from cache and list
                    item = GetItemFromCacheByFileName(e.FullPath);
                    RemoveItemFromLists(item);
                    break;

                case WatcherChangeTypes.Created:
                    WaitforFileIsReadable(e.FullPath);
                    // add item to cache and list
                    T newItem = LoadItemfromFile <T>(e.FullPath, Path.GetDirectoryName(e.FullPath));
                    AddItemtoCache(e.FullPath, newItem);
                    mFolderItemsList.Add(newItem);
                    break;
                }
            }
            SolutionRepository.RefreshParentFoldersSoucerControlStatus(Path.GetDirectoryName(e.FullPath));
        }
Beispiel #2
0
        private void HandleFileChange(FileSystemEventArgs e)
        {
            RepositoryItemBase item = null;

            switch (e.ChangeType)
            {
            case WatcherChangeTypes.Changed:
                WaitforFileIsReadable(e.FullPath);
                // reLoad the object to mem updating fields
                item = GetItemFromCacheByFileName(e.FullPath);
                NewRepositorySerializer.ReloadObjectFromFile(item);

                //Trigger so source control item can update if needed
                item.OnPropertyChanged(nameof(RepositoryItemBase.SourceControlStatus));

                break;

            case WatcherChangeTypes.Deleted:
                //remove from cache and list
                item = GetItemFromCacheByFileName(e.FullPath);
                RemoveItemFromLists((RepositoryItemBase)item);
                break;

            case WatcherChangeTypes.Created:
                WaitforFileIsReadable(e.FullPath);
                // add item to cache and list
                T newItem = LoadItemfromFile <T>(e.FullPath, Path.GetDirectoryName(e.FullPath));
                AddItemtoCache(e.FullPath, newItem);
                mFolderItemsList.Add(newItem);
                break;
            }
        }
Beispiel #3
0
        public override void ReloadUpdatedXML(string path)
        {
            WaitforFileIsReadable(path);
            RepositoryItemBase item = GetItemFromCacheByFileName(path);

            if (item != null)
            {
                NewRepositorySerializer.ReloadObjectFromFile(item);
                item.RefreshSourceControlStatus();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Clear folder items & sub folders cache recursive
        /// </summary>
        /// <param name="newFolderName"></param>
        //public override void ClearFolderCache()
        //{
        //    //Clear sub folders cache
        //    if (mSubFoldersCache != null)
        //    {
        //        foreach (RepositoryFolder<T> sf in mSubFoldersCache)
        //            sf.ClearFolderCache();

        //        mSubFoldersCache = null;
        //    }

        //    //clear folder items list
        //    if (mFolderItemsList != null)
        //    {
        //        //clear items from local & general items list
        //        while (mFolderItemsList.Count > 0)
        //        {
        //            if (mSolutionRepositoryItemInfo.AllItemsCache != null)
        //                mSolutionRepositoryItemInfo.AllItemsCache.Remove(mFolderItemsList[0]);

        //            mFolderItemsList.RemoveAt(0);
        //        }

        //        //mFolderItemsList.Clear();
        //        //mFolderItemsList = null;//making it null so list will be reloaded when GetITems will be called
        //    }

        //    //clear folder items cache
        //    mFolderItemsCache.Clear();
        //}

        /// <summary>
        /// Clear folder items & sub folders cache recursive and then reload the folder items to cache recursive
        /// </summary>
        /// <param name="newFolderName"></param>
        //public override void RefreshFolderCache()
        //{
        //    //clear cache
        //    ClearFolderCache();

        //    //reload items
        //    GetFolderItemsRecursive();
        //}


        //TO be used in rare cases were file watcher didn't catch a change!?
        public override void ReloadItems()
        {
            foreach (T item in mFolderItemsCache.Items <T>())
            {
                RepositoryItemBase ri = (RepositoryItemBase)(object)item;
                NewRepositorySerializer.ReloadObjectFromFile(ri);
            }

            //clear cache
            //ClearFolderCache();

            //reload items
            //GetFolderItemsRecursive();
        }