コード例 #1
0
    IEnumerator Start()
    {
        bool firstLoad = true;

        while (true)
        {
            if (File.Exists(_filePath))
            {
                string lastTimeFileModified = "" + DateTimeToUnixTimestamp(File.GetLastWriteTimeUtc(_filePath));;

                if (lastTimeFileModified != _lastTimeWrited)
                {
                    _lastTimeWrited = lastTimeFileModified;
                    _isUpdated      = false;
                }
                if (!_isUpdated)
                {
                    string fileContent = null;
                    try {
                        fileContent = File.ReadAllText(_filePath);

                        if (firstLoad && !string.IsNullOrEmpty(fileContent))
                        {
                            _onFirstLoad.Invoke(fileContent);
                        }
                        else if (!string.IsNullOrEmpty(fileContent))
                        {
                            _onFileChanged.Invoke(fileContent);
                        }

                        _fileUnreadable = false;
                        _isUpdated      = true;
                        firstLoad       = false;
                    }
                    catch (IOException)
                    {
                        _fileUnreadable = true;
                        //                  Debug.Log("File unreadabe");
                    }
                }
            }
            yield return(new WaitForEndOfFrame());
        }
    }
コード例 #2
0
ファイル: ViewManager.cs プロジェクト: dangwalsh/RealityLib
 static void OnFileChangedEvent(object sender, EventArgs e)
 {
     FileChangedEvent?.Invoke(sender, e);
 }
コード例 #3
0
 int IVsFileChangeEvents.DirectoryChanged(string pszDirectory)
 {
     FileChangedEvent?.Invoke(this, new TestFileChangedEventArgs(null, pszDirectory, TestFileChangedReason.Changed));
     return(VSConstants.S_OK);
 }