MegaBites-AI/Windows-powershell
0372
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Management.Automation.Internal;5 6using Dbg = System.Management.Automation;7 8namespace System.Management.Automation9{10 /// <summary>11 /// Exposes the Cmdlet Family Providers to the Cmdlet base class. The methods of this class12 /// use the providers to perform operations.13 /// </summary>14 public sealed class ProviderIntrinsics15 {16 #region Constructors17 18 /// <summary>19 /// Hide the default constructor since we always require an instance of SessionState.20 /// </summary>21 private ProviderIntrinsics()22 {23 Dbg.Diagnostics.Assert(24 false,25 "This constructor should never be called. Only the constructor that takes an instance of SessionState should be called.");26 }27 28 /// <summary>29 /// Constructs a facade over the "real" session state API.30 /// </summary>31 /// <param name="cmdlet">32 /// An instance of the cmdlet.33 /// </param>34 /// <exception cref="ArgumentNullException">35 /// If <paramref name="cmdlet"/> is null.36 /// </exception>37 internal ProviderIntrinsics(Cmdlet cmdlet)38 {39 if (cmdlet == null)40 {41 throw PSTraceSource.NewArgumentNullException(nameof(cmdlet));42 }43 44 _cmdlet = cmdlet;45 Item = new ItemCmdletProviderIntrinsics(cmdlet);46 ChildItem = new ChildItemCmdletProviderIntrinsics(cmdlet);47 Content = new ContentCmdletProviderIntrinsics(cmdlet);48 Property = new PropertyCmdletProviderIntrinsics(cmdlet);49 SecurityDescriptor = new SecurityDescriptorCmdletProviderIntrinsics(cmdlet);50 }51 52 /// <summary>53 /// Constructs a facade over the "real" session state API.54 /// </summary>55 /// <param name="sessionState">56 /// An instance of the cmdlet.57 /// </param>58 internal ProviderIntrinsics(SessionStateInternal sessionState)59 {60 if (sessionState == null)61 {62 throw PSTraceSource.NewArgumentNullException(nameof(sessionState));63 }64 65 Item = new ItemCmdletProviderIntrinsics(sessionState);66 ChildItem = new ChildItemCmdletProviderIntrinsics(sessionState);67 Content = new ContentCmdletProviderIntrinsics(sessionState);68 Property = new PropertyCmdletProviderIntrinsics(sessionState);69 SecurityDescriptor = new SecurityDescriptorCmdletProviderIntrinsics(sessionState);70 }71 72 #endregion Constructors73 74 #region Public members75 76 /// <summary>77 /// Gets the object that exposes the verbs for the item noun for Cmdlet Providers.78 /// </summary>79 public ItemCmdletProviderIntrinsics Item { get; }80 81 /// <summary>82 /// Gets the object that exposes the verbs for the childItem noun for Cmdlet Providers.83 /// </summary>84 public ChildItemCmdletProviderIntrinsics ChildItem { get; }85 86 /// <summary>87 /// Gets the object that exposes the verbs for the content noun for Cmdlet Providers.88 /// </summary>89 public ContentCmdletProviderIntrinsics Content { get; }90 91 /// <summary>92 /// Gets the object that exposes the verbs for the property noun for Cmdlet Providers.93 /// </summary>94 public PropertyCmdletProviderIntrinsics Property { get; }95 96 /// <summary>97 /// Gets the object that exposes the verbs for the SecurityDescriptor noun for Cmdlet Providers.98 /// </summary>99 public SecurityDescriptorCmdletProviderIntrinsics SecurityDescriptor { get; }100 101 #endregion Public members102 103 #region private data104 105 private readonly InternalCommand _cmdlet;106 107 #endregion private data108 }109}110 