/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ #pragma warning disable 1634, 1691 #pragma warning disable 56506 namespace System.Management.Automation.Runspaces { /// /// Define class for runspace configuration entry. /// /// /// This abstract class is to be derived internally by Monad for different /// runspace configuration entries only. Developers should not derive from /// this class. /// #if CORECLR internal #else public #endif abstract class RunspaceConfigurationEntry { /// /// Initiate an instance of runspace configuration entry. /// /// Name for the runspace configuration entry /// protected RunspaceConfigurationEntry(string name) { if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(name.Trim())) { throw PSTraceSource.NewArgumentNullException("name"); } Name = name.Trim(); } /// /// Initiate an instance of runspace configuration entry. /// /// Name for the runspace configuration entry /// The name of the PSSnapin the entry comes from. /// internal RunspaceConfigurationEntry(string name, PSSnapInInfo psSnapin) { if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(name.Trim())) { throw PSTraceSource.NewArgumentNullException("name"); } Name = name.Trim(); if (psSnapin == null) { throw PSTraceSource.NewArgumentException("psSnapin"); } PSSnapIn = psSnapin; } /// /// Gets name of configuration entry /// public string Name { get; } /// /// Gets name of PSSnapin that this configuration entry belongs to. /// public PSSnapInInfo PSSnapIn { get; } = null; internal bool _builtIn = false; /// /// Get whether this entry is a built-in entry. /// public bool BuiltIn { get { return _builtIn; } } internal UpdateAction _action = UpdateAction.None; internal UpdateAction Action { get { return _action; } } } /// /// Defines class for type configuration entry. /// #if CORECLR internal #else public #endif sealed class TypeConfigurationEntry : RunspaceConfigurationEntry { /// /// Initiate an instance for type configuration entry. /// /// Name of the type configuration entry /// File name that contains the types configuration information. /// when is null or empty public TypeConfigurationEntry(string name, string fileName) : base(name) { if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileName.Trim())) { throw PSTraceSource.NewArgumentException("fileName"); } FileName = fileName.Trim(); } /// /// Initiate an instance for type configuration entry. /// /// TypeData instance /// Specify the operation with the typedata public TypeConfigurationEntry(TypeData typeData, bool isRemove) : base("*") { if (typeData == null) { throw PSTraceSource.NewArgumentException("typeData"); } TypeData = typeData; IsRemove = isRemove; } /// /// Initiate an instance for type configuration entry. /// /// Name of the type configuration entry /// File name that contains the types configuration information. /// PSSnapin from which type info comes. /// when is null, empty or does not end in .ps1xml internal TypeConfigurationEntry(string name, string fileName, PSSnapInInfo psSnapinInfo) : base(name, psSnapinInfo) { if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileName.Trim())) { throw PSTraceSource.NewArgumentException("fileName"); } FileName = fileName.Trim(); } /// /// Initiate an instance for type configuration entry. /// /// File name that contains the types configuration information. /// when is null, empty or does not end in .ps1xml public TypeConfigurationEntry(string fileName) : base(fileName) { if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileName.Trim())) { throw PSTraceSource.NewArgumentException("fileName"); } #pragma warning suppress 56506 FileName = fileName.Trim(); } /// /// Gets file name that contains the types configuration information. /// /// public string FileName { get; } /// /// Get the strong type data contains the type configuration information /// public TypeData TypeData { get; } /// /// Set to true if the strong type data is to be removed /// public bool IsRemove { get; } } /// /// Defines class for type configuration entry. /// #if CORECLR internal #else public #endif sealed class FormatConfigurationEntry : RunspaceConfigurationEntry { /// /// Initiate an instance for type configuration entry. /// /// Name of the format configuration entry /// File name that contains the format configuration information. /// when is null or empty public FormatConfigurationEntry(string name, string fileName) : base(name) { if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileName.Trim())) { throw PSTraceSource.NewArgumentException("fileName"); } FileName = fileName.Trim(); } /// /// Initiate an instance for Format configuration entry. /// /// Name of the Format configuration entry /// File name that contains the Formats configuration information. /// PSSnapin from which the format comes. /// when is null, empty or does not end in .ps1xml internal FormatConfigurationEntry(string name, string fileName, PSSnapInInfo psSnapinInfo) : base(name, psSnapinInfo) { if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileName.Trim())) { throw PSTraceSource.NewArgumentException("fileName"); } FileName = fileName.Trim(); } /// /// Initiate an instance for type configuration entry. /// /// File name that contains the format configuration information. /// when is null or empty public FormatConfigurationEntry(string fileName) : base(fileName) { if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileName.Trim())) { throw PSTraceSource.NewArgumentException("fileName"); } #pragma warning suppress 56506 FileName = fileName.Trim(); } /// /// Initiate an instance for type configuration entry. /// /// public FormatConfigurationEntry(ExtendedTypeDefinition typeDefinition) : base("*") { if (typeDefinition == null) { throw PSTraceSource.NewArgumentNullException("typeDefinition"); } FormatData = typeDefinition; } /// /// Gets file name that contains the format configuration information. /// /// File name that contains the format configuration information. public string FileName { get; } /// /// Get the typeDefinition that contains the format configuration information /// public ExtendedTypeDefinition FormatData { get; } } /// /// Class to define configuration data for cmdlets /// #if CORECLR internal #else public #endif sealed class CmdletConfigurationEntry : RunspaceConfigurationEntry { /// /// Initiate an instance for cmdlet configuration entry. /// /// Name of the cmdlet configuration entry /// Class that include implementation of the cmdlet /// Name of the help file that include help information for the cmdlet public CmdletConfigurationEntry(string name, Type implementingType, string helpFileName) : base(name) { if (implementingType == null) { throw PSTraceSource.NewArgumentNullException("implementingType"); } ImplementingType = implementingType; if (!String.IsNullOrEmpty(helpFileName)) { HelpFileName = helpFileName.Trim(); } else { HelpFileName = helpFileName; } } /// /// Initiate an instance for cmdlet configuration entry. /// /// Name of the cmdlet configuration entry /// Class that include implementation of the cmdlet /// PSSnapin from which the cmdlet comes. /// Name of the help file that include help information for the cmdlet internal CmdletConfigurationEntry(string name, Type implementingType, string helpFileName, PSSnapInInfo psSnapinInfo) : base(name, psSnapinInfo) { if (implementingType == null) { throw PSTraceSource.NewArgumentNullException("implementingType"); } ImplementingType = implementingType; if (!String.IsNullOrEmpty(helpFileName)) { HelpFileName = helpFileName.Trim(); } else { HelpFileName = helpFileName; } } /// /// Get class that include implementation of the cmdlet /// public Type ImplementingType { get; } /// /// Get name of the help file that include help information for the cmdlet /// /// public string HelpFileName { get; } } /// /// Define class for provider configuration entry /// #if CORECLR internal #else public #endif sealed class ProviderConfigurationEntry : RunspaceConfigurationEntry { /// /// Initiate an instance for provider configuration entry. /// /// Name of the provider configuration entry /// Class that include implementation of the provider /// Name of the help file that include help information for the provider public ProviderConfigurationEntry(string name, Type implementingType, string helpFileName) : base(name) { if (implementingType == null) { throw PSTraceSource.NewArgumentNullException("implementingType"); } ImplementingType = implementingType; if (!String.IsNullOrEmpty(helpFileName)) { HelpFileName = helpFileName.Trim(); } else { HelpFileName = helpFileName; } } /// /// Initiate an instance for provider configuration entry. /// /// Name of the provider configuration entry /// Class that include implementation of the provider /// Name of the help file that include help information for the provider /// PSSnapin from which provider comes from. internal ProviderConfigurationEntry(string name, Type implementingType, string helpFileName, PSSnapInInfo psSnapinInfo) : base(name, psSnapinInfo) { if (implementingType == null) { throw PSTraceSource.NewArgumentNullException("implementingType"); } ImplementingType = implementingType; if (!String.IsNullOrEmpty(helpFileName)) { HelpFileName = helpFileName.Trim(); } else { HelpFileName = helpFileName; } } /// /// Get class that include implementation of the provider. /// /// public Type ImplementingType { get; } /// /// Get name of the help file that include help information for the provider /// public string HelpFileName { get; } } /// /// Define class for script configuration entry /// #if CORECLR internal #else public #endif sealed class ScriptConfigurationEntry : RunspaceConfigurationEntry { /// /// Initiate an instance for script configuration entry. /// /// Name of the script configuration entry /// Content of the script public ScriptConfigurationEntry(string name, string definition) : base(name) { if (String.IsNullOrEmpty(definition) || String.IsNullOrEmpty(definition.Trim())) { throw PSTraceSource.NewArgumentNullException("definition"); } Definition = definition.Trim(); } /// /// Get content for the script. /// public string Definition { get; } } /// /// Configuration data for assemblies. /// #if CORECLR internal #else public #endif sealed class AssemblyConfigurationEntry : RunspaceConfigurationEntry { /// /// Initiate an instance for assembly configuration entry. /// /// Strong name of the assembly /// Name of the assembly file public AssemblyConfigurationEntry(string name, string fileName) : base(name) { if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileName.Trim())) { throw PSTraceSource.NewArgumentNullException("fileName"); } FileName = fileName.Trim(); } /// /// Initiate an instance for assembly configuration entry. /// /// Strong name of the assembly /// Name of the assembly file /// PSSnapin information. /// when is null, empty or does not end in .ps1xml internal AssemblyConfigurationEntry(string name, string fileName, PSSnapInInfo psSnapinInfo) : base(name, psSnapinInfo) { if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(fileName.Trim())) { throw PSTraceSource.NewArgumentNullException("fileName"); } FileName = fileName.Trim(); } /// /// Get name of the assembly file /// /// Name of the assembly file public string FileName { get; } } internal enum UpdateAction { Add, Remove, None } } #pragma warning restore 56506