Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TextDocumentFileActionEventArgs.cs « Document « TextData « Def « Text « src - github.com/microsoft/vs-editor-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e94e9ae50b0e8b4e0626202ad7eca8061db266ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//
//  Copyright (c) Microsoft Corporation. All rights reserved.
//  Licensed under the MIT License. See License.txt in the project root for license information.
//
namespace Microsoft.VisualStudio.Text
{
    using System;

    /// <summary>
    /// Describes the type of file action.
    /// </summary>
    [Flags]
    public enum FileActionTypes
    {
        /// <summary>
        /// The content was saved to disk.
        /// </summary>
        ContentSavedToDisk = 1,

        /// <summary>
        /// The content was loaded from disk.
        /// </summary>
        ContentLoadedFromDisk = 2,

        /// <summary>
        /// The document was renamed.
        /// </summary>
        DocumentRenamed = 4
    }

    /// <summary>
    /// Provides information for events that are raised when an <see cref="ITextDocument"/> has loaded from or saved to disk.
    /// </summary>
    public class TextDocumentFileActionEventArgs : EventArgs
    {
        #region Private Members

        string _filePath;
        DateTime _time;
        FileActionTypes _fileActionType;

        #endregion

        /// <summary>
        /// Initializes a new instance of a <see cref="TextDocumentFileActionEventArgs"/> for a file action event.
        /// </summary>
        /// <param name="filePath">The path to the file.</param>
        /// <param name="time">The <see cref="DateTime"/> when the file action occurred.</param>
        /// <param name="fileActionType">The <see cref="FileActionTypes"/> that occurred.</param>
        /// <exception cref="ArgumentNullException"><paramref name="filePath"/> is null.</exception>
        public TextDocumentFileActionEventArgs(string filePath, DateTime time, FileActionTypes fileActionType)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            _filePath = filePath;
            _time = time;
            _fileActionType = fileActionType;
        }

        #region Public Properties

        /// <summary>
        /// Gets the path to the file.
        /// </summary>
        public string FilePath
        {
            get
            {
                return _filePath;
            }
        }

        /// <summary>
        /// Gets the <see cref="DateTime"/> when the file action occurred.
        /// </summary>
        public DateTime Time
        {
            get
            {
                return _time;
            }
        }

        /// <summary>
        /// Gets the <see cref="FileActionTypes"/> that occurred.
        /// </summary>
        public FileActionTypes FileActionType
        {
            get
            {
                return _fileActionType;
            }
        }

        #endregion
    }
}