Esempio n. 1
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="dictionary"></param>
        public DictionaryWatcher(EfsSystem system, Dictionary dictionary)
        {
            System     = system;
            Dictionary = dictionary;
            LastChange = DateTime.Now;
            DeltaTime  = new TimeSpan(0, 0, 2);

            CriticalRegion = new Mutex(false, "Critical region");

            if (dictionary.FilePath != null)
            {
                if (dictionary.countNameSpaces() > 0)
                {
                    string path = Path.GetDirectoryName(dictionary.FilePath) + Path.DirectorySeparatorChar +
                                  Path.GetFileNameWithoutExtension(dictionary.FilePath);
                    path = Path.GetFullPath(path);
                    Directory.CreateDirectory(path);
                    Watcher = new FileSystemWatcher(path, "*.*")
                    {
                        IncludeSubdirectories = true,
                        NotifyFilter          = NotifyFilters.LastWrite
                    };
                }
                else
                {
                    string path     = Path.GetDirectoryName(dictionary.FilePath);
                    string fileName = Path.GetFileName(dictionary.FilePath);
                    Watcher = new FileSystemWatcher(path, fileName)
                    {
                        IncludeSubdirectories = false,
                        NotifyFilter          = NotifyFilters.LastWrite
                    };
                }

                Watcher.Changed += Watcher_Changed;
                Watcher.Created += Watcher_Changed;
                Watcher.Deleted += Watcher_Changed;

                StartWatching();
            }
        }
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="dictionary"></param>
        public DictionaryWatcher(EfsSystem system, Dictionary dictionary)
        {
            System = system;
            Dictionary = dictionary;
            LastChange = DateTime.Now;
            DeltaTime = new TimeSpan(0, 0, 2);

            CriticalRegion = new Mutex(false, "Critical region");

            if (dictionary.FilePath != null)
            {
                if (dictionary.countNameSpaces() > 0)
                {
                    string path = Path.GetDirectoryName(dictionary.FilePath) + Path.DirectorySeparatorChar +
                                  Path.GetFileNameWithoutExtension(dictionary.FilePath);
                    path = Path.GetFullPath(path);
                    Directory.CreateDirectory(path);
                    Watcher = new FileSystemWatcher(path, "*.*")
                    {
                        IncludeSubdirectories = true,
                        NotifyFilter = NotifyFilters.LastWrite
                    };
                }
                else
                {
                    string path = Path.GetDirectoryName(dictionary.FilePath);
                    string fileName = Path.GetFileName(dictionary.FilePath);
                    Watcher = new FileSystemWatcher(path, fileName)
                    {
                        IncludeSubdirectories = false,
                        NotifyFilter = NotifyFilters.LastWrite
                    };
                }

                Watcher.Changed += Watcher_Changed;
                Watcher.Created += Watcher_Changed;
                Watcher.Deleted += Watcher_Changed;

                StartWatching();
            }
        }
Esempio n. 3
0
            public override void visit(Generated.Dictionary obj, bool visitSubNodes)
            {
                base.visit(obj, visitSubNodes);

                Dictionary dictionary = (Dictionary)obj;

                if (_beforeSave)
                {
                    dictionary.ClearTempFiles();
                    dictionary.allNameSpaceRefs().Clear();
                    dictionary.allTestRefs().Clear();

                    // Only split namespace and test files when the dictionary holds namespaces
                    if (dictionary.countNameSpaces() > 0)
                    {
                        foreach (Types.NameSpace subNameSpace in dictionary.allNameSpaces())
                        {
                            dictionary.appendNameSpaceRefs(referenceNameSpace(dictionary, subNameSpace));
                        }

                        if (dictionary.allTests() != null)
                        {
                            foreach (Frame frame in dictionary.allTests())
                            {
                                dictionary.appendTestRefs(referenceFrame(dictionary, frame));
                            }
                        }
                        dictionary.StoreInfo();
                    }
                }
                else
                {
                    // Only build back split information when the dictionary held namespaces
                    if (dictionary._savedNameSpaces != null && dictionary._savedNameSpaces.Count > 0)
                    {
                        dictionary.RestoreInfo();
                    }
                }
            }