File tree Expand file tree Collapse file tree 4 files changed +106
-0
lines changed
src/PowerShellEditorServices/Providers Expand file tree Collapse file tree 4 files changed +106
-0
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ namespace Microsoft . PowerShell . EditorServices
7
+ {
8
+ /// <summary>
9
+ /// Defines the contract for a feature provider, particularly for provider identification.
10
+ /// </summary>
11
+ public interface IProvider
12
+ {
13
+ /// <summary>
14
+ /// Specifies a unique identifier for a provider, typically a
15
+ /// fully-qualified name like "Microsoft.PowerShell.EditorServices.MyProvider"
16
+ /// </summary>
17
+ string ProviderId { get ; }
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ using System . Collections . Generic ;
7
+
8
+ namespace Microsoft . PowerShell . EditorServices
9
+ {
10
+ /// <summary>
11
+ /// Defines the contract for a collection of provider implementations.
12
+ /// </summary>
13
+ public interface IProviderCollection < TProvider > : IEnumerable < TProvider >
14
+ where TProvider : IProvider
15
+ {
16
+ /// <summary>
17
+ /// Adds a provider to the collection.
18
+ /// </summary>
19
+ /// <param name="provider">The provider to be added.</param>
20
+ void Add ( TProvider provider ) ;
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ namespace Microsoft . PowerShell . EditorServices
7
+ {
8
+ /// <summary>
9
+ /// Provides a base implementation of IProvider.
10
+ /// </summary>
11
+ public abstract class ProviderBase : IProvider
12
+ {
13
+ /// <summary>
14
+ /// Gets the provider class type's FullName as the
15
+ /// ProviderId.
16
+ /// </summary>
17
+ public string ProviderId => this . GetType ( ) . FullName ;
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) Microsoft. All rights reserved.
3
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ using System ;
7
+ using System . Collections ;
8
+ using System . Collections . Generic ;
9
+
10
+ namespace Microsoft . PowerShell . EditorServices
11
+ {
12
+ /// <summary>
13
+ /// Provides a default implementation of IProviderCollection.
14
+ /// </summary>
15
+ public class ProviderCollection < TProvider > : IProviderCollection < TProvider >
16
+ where TProvider : IProvider
17
+ {
18
+ #region Private Fields
19
+
20
+ private List < TProvider > providerList = new List < TProvider > ( ) ;
21
+
22
+ #endregion
23
+
24
+ #region IProviderCollection Implementation
25
+
26
+ void IProviderCollection < TProvider > . Add ( TProvider provider )
27
+ {
28
+ if ( ! this . providerList . Contains ( provider ) )
29
+ {
30
+ this . providerList . Add ( provider ) ;
31
+ }
32
+ }
33
+
34
+ IEnumerator < TProvider > IEnumerable < TProvider > . GetEnumerator ( )
35
+ {
36
+ return this . providerList . GetEnumerator ( ) ;
37
+ }
38
+
39
+ IEnumerator IEnumerable . GetEnumerator ( )
40
+ {
41
+ return this . providerList . GetEnumerator ( ) ;
42
+ }
43
+
44
+ #endregion
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments