public PSObject AsCustomObject() { if (this._sessionState == null) { throw PSTraceSource.NewInvalidOperationException("Modules", "InvalidOperationOnBinaryModule", new object[0]); } PSObject obj2 = new PSObject(); foreach (KeyValuePair <string, FunctionInfo> pair in this.ExportedFunctions) { FunctionInfo info = pair.Value; if (info != null) { PSScriptMethod member = new PSScriptMethod(info.Name, info.ScriptBlock); obj2.Members.Add(member); } } foreach (KeyValuePair <string, PSVariable> pair2 in this.ExportedVariables) { PSVariable variable = pair2.Value; if (variable != null) { PSVariableProperty property = new PSVariableProperty(variable); obj2.Members.Add(property); } } return(obj2); }
/// <summary> /// A helper method for creating an object that represents a total count /// of objects that the cmdlet would return without paging /// (this can be more than the size of the page specified in the <see cref="First"/> cmdlet parameter). /// </summary> /// <param name="totalCount">a total count of objects that the cmdlet would return without paging.</param> /// <param name="accuracy"> /// accuracy of the <paramref name="totalCount"/> parameter. /// <c>1.0</c> means 100% accurate; /// <c>0.0</c> means that total count is unknown; /// anything in-between means that total count is estimated /// </param> /// <returns>An object that represents a total count of objects that the cmdlet would return without paging.</returns> public PSObject NewTotalCount(UInt64 totalCount, double accuracy) { PSObject result = new PSObject(totalCount); string toStringMethodBody = string.Format( CultureInfo.CurrentCulture, @" $totalCount = $this.PSObject.BaseObject switch ($this.Accuracy) {{ {{ $_ -ge 1.0 }} {{ '{0}' -f $totalCount }} {{ $_ -le 0.0 }} {{ '{1}' -f $totalCount }} default {{ '{2}' -f $totalCount }} }} ", CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportAccurateTotalCountTemplate), CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportUnknownTotalCountTemplate), CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportEstimatedTotalCountTemplate)); PSScriptMethod toStringMethod = new PSScriptMethod("ToString", ScriptBlock.Create(toStringMethodBody)); result.Members.Add(toStringMethod); accuracy = Math.Max(0.0, Math.Min(1.0, accuracy)); PSNoteProperty statusProperty = new PSNoteProperty("Accuracy", accuracy); result.Members.Add(statusProperty); return(result); }
/// <summary> /// A helper method for creating an object that represents a total count /// of objects that the cmdlet would return without paging /// (this can be more than the size of the page specified in the <see cref="First"/> cmdlet parameter). /// </summary> /// <param name="totalCount">a total count of objects that the cmdlet would return without paging</param> /// <param name="accuracy"> /// accuracy of the <paramref name="totalCount"/> parameter. /// <c>1.0</c> means 100% accurate; /// <c>0.0</c> means that total count is unknown; /// anything in-between means that total count is estimated /// </param> /// <returns>An object that represents a total count of objects that the cmdlet would return without paging</returns> public PSObject NewTotalCount(UInt64 totalCount, double accuracy) { PSObject result = new PSObject(totalCount); string toStringMethodBody = string.Format( CultureInfo.CurrentCulture, @" $totalCount = $this.PSObject.BaseObject switch ($this.Accuracy) {{ {{ $_ -ge 1.0 }} {{ '{0}' -f $totalCount }} {{ $_ -le 0.0 }} {{ '{1}' -f $totalCount }} default {{ '{2}' -f $totalCount }} }} ", CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportAccurateTotalCountTemplate), CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportUnknownTotalCountTemplate), CodeGeneration.EscapeSingleQuotedStringContent(CommandBaseStrings.PagingSupportEstimatedTotalCountTemplate)); PSScriptMethod toStringMethod = new PSScriptMethod("ToString", ScriptBlock.Create(toStringMethodBody)); result.Members.Add(toStringMethod); accuracy = Math.Max(0.0, Math.Min(1.0, accuracy)); PSNoteProperty statusProperty = new PSNoteProperty("Accuracy", accuracy); result.Members.Add(statusProperty); return result; }
public override PSMemberInfo Copy() { PSScriptMethod destiny = new PSScriptMethod(base.name, this.script) { shouldCloneOnAccess = this.shouldCloneOnAccess }; base.CloneBaseProperties(destiny); return destiny; }
public override PSMemberInfo Copy() { PSScriptMethod destiny = new PSScriptMethod(base.name, this.script) { shouldCloneOnAccess = this.shouldCloneOnAccess }; base.CloneBaseProperties(destiny); return(destiny); }
public PSObject NewTotalCount(ulong totalCount, double accuracy) { PSObject obj2 = new PSObject(totalCount); string script = string.Format(CultureInfo.CurrentCulture, "\r\n $totalCount = $this.PSObject.BaseObject\r\n switch ($this.Accuracy) {{\r\n {{ $_ -ge 1.0 }} {{ '{0}' -f $totalCount }}\r\n {{ $_ -le 0.0 }} {{ '{1}' -f $totalCount }}\r\n default {{ '{2}' -f $totalCount }}\r\n }}\r\n ", new object[] { CommandMetadata.EscapeSingleQuotedString(CommandBaseStrings.PagingSupportAccurateTotalCountTemplate), CommandMetadata.EscapeSingleQuotedString(CommandBaseStrings.PagingSupportUnknownTotalCountTemplate), CommandMetadata.EscapeSingleQuotedString(CommandBaseStrings.PagingSupportEstimatedTotalCountTemplate) }); PSScriptMethod member = new PSScriptMethod("ToString", ScriptBlock.Create(script)); obj2.Members.Add(member); accuracy = Math.Max(0.0, Math.Min(1.0, accuracy)); PSNoteProperty property = new PSNoteProperty("Accuracy", accuracy); obj2.Members.Add(property); return obj2; }
public PSObject NewTotalCount(ulong totalCount, double accuracy) { PSObject obj2 = new PSObject(totalCount); string script = string.Format(CultureInfo.CurrentCulture, "\r\n $totalCount = $this.PSObject.BaseObject\r\n switch ($this.Accuracy) {{\r\n {{ $_ -ge 1.0 }} {{ '{0}' -f $totalCount }}\r\n {{ $_ -le 0.0 }} {{ '{1}' -f $totalCount }}\r\n default {{ '{2}' -f $totalCount }}\r\n }}\r\n ", new object[] { CommandMetadata.EscapeSingleQuotedString(CommandBaseStrings.PagingSupportAccurateTotalCountTemplate), CommandMetadata.EscapeSingleQuotedString(CommandBaseStrings.PagingSupportUnknownTotalCountTemplate), CommandMetadata.EscapeSingleQuotedString(CommandBaseStrings.PagingSupportEstimatedTotalCountTemplate) }); PSScriptMethod member = new PSScriptMethod("ToString", ScriptBlock.Create(script)); obj2.Members.Add(member); accuracy = Math.Max(0.0, Math.Min(1.0, accuracy)); PSNoteProperty property = new PSNoteProperty("Accuracy", accuracy); obj2.Members.Add(property); return(obj2); }
public PSObject AsCustomObject() { if (this._sessionState == null) { throw PSTraceSource.NewInvalidOperationException("Modules", "InvalidOperationOnBinaryModule", new object[0]); } PSObject obj2 = new PSObject(); foreach (KeyValuePair<string, FunctionInfo> pair in this.ExportedFunctions) { FunctionInfo info = pair.Value; if (info != null) { PSScriptMethod member = new PSScriptMethod(info.Name, info.ScriptBlock); obj2.Members.Add(member); } } foreach (KeyValuePair<string, PSVariable> pair2 in this.ExportedVariables) { PSVariable variable = pair2.Value; if (variable != null) { PSVariableProperty property = new PSVariableProperty(variable); obj2.Members.Add(property); } } return obj2; }