Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes308downloads
DscResourceInfo.cs164 linesDownload Raw Back to engine
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Collections.Generic;5using System.Collections.ObjectModel;6 7namespace System.Management.Automation8{9    /// <summary>10    /// Enumerated values for DSC resource implementation type.11    /// </summary>12    public enum ImplementedAsType13    {14        /// <summary>15        /// DSC resource implementation type not known.16        /// </summary>17        None = 0,18 19        /// <summary>20        /// DSC resource is implemented using PowerShell module.21        /// </summary>22        PowerShell = 1,23 24        /// <summary>25        /// DSC resource is implemented using a CIM provider.26        /// </summary>27        Binary = 2,28 29        /// <summary>30        /// DSC resource is a composite and implemented using configuration keyword.31        /// </summary>32        Composite = 333    }34 35    /// <summary>36    /// Contains a DSC resource information.37    /// </summary>38    public class DscResourceInfo39    {40        /// <summary>41        /// Initializes a new instance of the DscResourceInfo class.42        /// </summary>43        /// <param name="name">Name of the DscResource.</param>44        /// <param name="friendlyName">FriendlyName of the DscResource.</param>45        /// <param name="path">Path of the DscResource.</param>46        /// <param name="parentPath">ParentPath of the DscResource.</param>47        /// <param name="context">The execution context for the DscResource.</param>48        internal DscResourceInfo(string name, string friendlyName, string path, string parentPath, ExecutionContext context)49        {50            this.Name = name;51            this.FriendlyName = friendlyName;52            this.Path = path;53            this.ParentPath = parentPath;54            this.Properties = new ReadOnlyCollection<DscResourcePropertyInfo>(new List<DscResourcePropertyInfo>());55        }56 57        /// <summary>58        /// Name of the DSC Resource.59        /// </summary>60        public string Name { get; }61 62        /// <summary>63        /// Gets or sets resource type name.64        /// </summary>65        public string ResourceType { get; set; }66 67        /// <summary>68        /// Gets or sets friendly name defined for the resource.69        /// </summary>70        public string FriendlyName { get; set; }71 72        /// <summary>73        /// Gets or sets of the file which implements the resource. For the resources which are defined using74        /// MOF file, this will be path to a module which resides in the same folder where schema.mof file is present.75        /// For composite resources, this will be the module which implements the resource.76        /// </summary>77        public string Path { get; set; }78 79        /// <summary>80        /// Gets or sets parent folder, where the resource is defined81        /// It is the folder containing either the implementing module(=Path) or folder containing ".schema.mof".82        /// For native providers, Path will be null and only ParentPath will be present.83        /// </summary>84        public string ParentPath { get; set; }85 86        /// <summary>87        /// Gets or sets a value which indicate how DSC resource is implemented.88        /// </summary>89        public ImplementedAsType ImplementedAs { get; set; }90 91        /// <summary>92        /// Gets or sets company which owns this resource.93        /// </summary>94        public string CompanyName { get; set; }95 96        /// <summary>97        /// Gets or sets properties of the resource.98        /// </summary>99        public ReadOnlyCollection<DscResourcePropertyInfo> Properties { get; private set; }100 101        /// <summary>102        /// Updates properties of the resource.103        /// </summary>104        /// <param name="properties">Updated properties.</param>105        public void UpdateProperties(IList<DscResourcePropertyInfo> properties)106        {107            if (properties != null)108                this.Properties = new ReadOnlyCollection<DscResourcePropertyInfo>(properties);109        }110 111        /// <summary>112        /// Module in which the DscResource is implemented in.113        /// </summary>114        public PSModuleInfo Module { get; internal set; }115 116        /// <summary>117        /// Gets the help file path for the cmdlet.118        /// </summary>119        public string HelpFile { get; internal set; } = string.Empty;120 121        // HelpFile122    }123 124    /// <summary>125    /// Contains a DSC resource property information.126    /// </summary>127    public sealed class DscResourcePropertyInfo128    {129        /// <summary>130        /// Initializes a new instance of the DscResourcePropertyInfo class.131        /// </summary>132        internal DscResourcePropertyInfo()133        {134            this.Values = new ReadOnlyCollection<string>(new List<string>());135        }136 137        /// <summary>138        /// Gets or sets name of the property.139        /// </summary>140        public string Name { get; set; }141 142        /// <summary>143        /// Gets or sets type of the property.144        /// </summary>145        public string PropertyType { get; set; }146 147        /// <summary>148        /// Gets or sets a value indicating whether the property is mandatory or not.149        /// </summary>150        public bool IsMandatory { get; set; }151 152        /// <summary>153        /// Gets Values for a resource property.154        /// </summary>155        public ReadOnlyCollection<string> Values { get; private set; }156 157        internal void UpdateValues(IList<string> values)158        {159            if (values != null)160                this.Values = new ReadOnlyCollection<string>(values);161        }162    }163}164