internal void Update(System.Management.Automation.ScriptBlock newFunction, bool force, ScopedItemOptions options, string helpFile) { if (newFunction == null) { throw PSTraceSource.NewArgumentNullException("function"); } if ((this._options & ScopedItemOptions.Constant) != ScopedItemOptions.None) { SessionStateUnauthorizedAccessException exception = new SessionStateUnauthorizedAccessException(base.Name, SessionStateCategory.Function, "FunctionIsConstant", SessionStateStrings.FunctionIsConstant); throw exception; } if (!force && ((this._options & ScopedItemOptions.ReadOnly) != ScopedItemOptions.None)) { SessionStateUnauthorizedAccessException exception2 = new SessionStateUnauthorizedAccessException(base.Name, SessionStateCategory.Function, "FunctionIsReadOnly", SessionStateStrings.FunctionIsReadOnly); throw exception2; } this._scriptBlock = newFunction; base.SetModule(newFunction.Module); this._commandMetadata = null; base._parameterSets = null; base._externalCommandMetadata = null; if (options != ScopedItemOptions.Unspecified) { this.Options = options; } this._helpFile = helpFile; }
internal static Collection <CommandParameterSetInfo> GetParameterMetadata(System.Management.Automation.CommandMetadata metadata, MergedCommandParameterMetadata parameterMetadata) { Collection <CommandParameterSetInfo> collection = new Collection <CommandParameterSetInfo>(); if (parameterMetadata != null) { if (parameterMetadata.ParameterSetCount == 0) { collection.Add(new CommandParameterSetInfo("__AllParameterSets", false, int.MaxValue, parameterMetadata)); return(collection); } int parameterSetCount = parameterMetadata.ParameterSetCount; for (int i = 0; i < parameterSetCount; i++) { int parameterSet = ((int)1) << i; string parameterSetName = parameterMetadata.GetParameterSetName(parameterSet); bool isDefaultParameterSet = (parameterSet & metadata.DefaultParameterSetFlag) != 0; collection.Add(new CommandParameterSetInfo(parameterSetName, isDefaultParameterSet, parameterSet, parameterMetadata)); } } return(collection); }
internal static Collection <CommandParameterSetInfo> GetCacheableMetadata(System.Management.Automation.CommandMetadata metadata) { return(GetParameterMetadata(metadata, metadata.StaticCommandParameterMetadata)); }
internal void Update(System.Management.Automation.ScriptBlock newFunction, bool force, ScopedItemOptions options, string helpFile) { if (newFunction == null) { throw PSTraceSource.NewArgumentNullException("function"); } if ((this._options & ScopedItemOptions.Constant) != ScopedItemOptions.None) { SessionStateUnauthorizedAccessException exception = new SessionStateUnauthorizedAccessException(base.Name, SessionStateCategory.Function, "FunctionIsConstant", SessionStateStrings.FunctionIsConstant); throw exception; } if (!force && ((this._options & ScopedItemOptions.ReadOnly) != ScopedItemOptions.None)) { SessionStateUnauthorizedAccessException exception2 = new SessionStateUnauthorizedAccessException(base.Name, SessionStateCategory.Function, "FunctionIsReadOnly", SessionStateStrings.FunctionIsReadOnly); throw exception2; } this._scriptBlock = newFunction; base.SetModule(newFunction.Module); this._commandMetadata = null; base._parameterSets = null; base._externalCommandMetadata = null; if (options != ScopedItemOptions.Unspecified) { this.Options = options; } this._helpFile = helpFile; }