/// <summary> /// Implements the process action of the command /// </summary> protected override void ProcessRecord() { if (_NoAdjustment) { _Pipeline.Process(InputObject); } else { PSObject item = PSObject.AsPSObject(_Pipeline.Process(InputObject).GetValue(0)); if (KeepInputObject.ToBool()) { PSObject tempItem = item; item = InputObject; foreach (PSPropertyInfo info in tempItem.Properties.Where(o => !item.Properties.Select(n => n.Name).Contains(o.Name))) { item.Properties.Add(info); } } if (ShowProperty.Length > 0) { item.Members.Add(new PSMemberSet("PSStandardMembers", _DisplayPropertySet)); } else if (ShowExcludeProperty.Length > 0) { item.Members.Add(new PSMemberSet("PSStandardMembers", new PSMemberInfo[] { new PSPropertySet("DefaultDisplayPropertySet", item.Properties.Select(o => o.Name).Where(o => !ShowExcludeProperty.Contains(o))) })); } if (!String.IsNullOrEmpty(TypeName)) { item.TypeNames.Insert(0, TypeName); } WriteObject(item); } }
protected override void ProcessRecord() { foreach (PSObject line in _pipe.Process(InputObject)) { _writer.Write(line.BaseObject.ToString()); _writer.WriteLine(); } }
/// <summary> /// ProcessRecord override. /// </summary> protected override void ProcessRecord() { _stepPipeline.Process(InputObject); WriteObject(InputObject); }
/// <summary> /// Override ProcessRecord. /// </summary> protected override void ProcessRecord() { object inpObj = InputObject.BaseObject; if (inpObj is MarkdownInfo markdownInfo) { if (UseBrowser) { var html = markdownInfo.Html; if (!string.IsNullOrEmpty(html)) { string tmpFilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".html"); try { using (var writer = new StreamWriter(new FileStream(tmpFilePath, FileMode.Create, FileAccess.Write, FileShare.Write))) { writer.Write(html); } } catch (Exception e) { var errorRecord = new ErrorRecord( e, "ErrorWritingTempFile", ErrorCategory.WriteError, tmpFilePath); WriteError(errorRecord); return; } if (InternalTestHooks.ShowMarkdownOutputBypass) { WriteObject(html); return; } try { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = tmpFilePath; startInfo.UseShellExecute = true; Process.Start(startInfo); } catch (Exception e) { var errorRecord = new ErrorRecord( e, "ErrorLaunchingDefaultApplication", ErrorCategory.InvalidOperation, targetObject: null); WriteError(errorRecord); return; } } else { string errorMessage = StringUtil.Format(ConvertMarkdownStrings.MarkdownInfoInvalid, "Html"); var errorRecord = new ErrorRecord( new InvalidDataException(errorMessage), "HtmlIsNullOrEmpty", ErrorCategory.InvalidData, html); WriteError(errorRecord); } } else { var vt100String = markdownInfo.VT100EncodedString; if (!string.IsNullOrEmpty(vt100String)) { if (InternalTestHooks.ShowMarkdownOutputBypass) { WriteObject(vt100String); return; } if (stepPipe != null) { stepPipe.Process(vt100String); } } else { string errorMessage = StringUtil.Format(ConvertMarkdownStrings.MarkdownInfoInvalid, "VT100EncodedString"); var errorRecord = new ErrorRecord( new InvalidDataException(errorMessage), "VT100EncodedStringIsNullOrEmpty", ErrorCategory.InvalidData, vt100String); WriteError(errorRecord); } } } else { string errorMessage = StringUtil.Format(ConvertMarkdownStrings.InvalidInputObjectType, inpObj.GetType()); var errorRecord = new ErrorRecord( new ArgumentException(errorMessage), "InvalidInputObject", ErrorCategory.InvalidArgument, InputObject); WriteError(errorRecord); } }
/// <summary> /// Implements the process action of the command /// </summary> protected override void ProcessRecord() { if (_NoAdjustment) { _Pipeline.Process(InputObject); } else { PSObject item = PSObject.AsPSObject(_Pipeline.Process(InputObject).GetValue(0)); if (KeepInputObject.ToBool()) { PSObject tempItem = item; item = InputObject; foreach (PSPropertyInfo info in tempItem.Properties.Where(o => !item.Properties.Select(n => n.Name).Contains(o.Name))) { item.Properties.Add(info); } } if (Alias != null) { foreach (SelectAliasParameter alias in Alias) { foreach (PSAliasProperty aliasItem in alias.Aliases) { item.Members.Add(aliasItem); } } } if (ScriptMethod != null) { foreach (SelectScriptMethodParameter method in ScriptMethod) { foreach (PSScriptMethod methodItem in method.Methods) { item.Members.Add(methodItem); } } } if (ScriptProperty != null) { foreach (SelectScriptPropertyParameter property in ScriptProperty) { foreach (PSScriptProperty propertyItem in property.Value) { item.Members.Add(propertyItem); } } } if (ShowProperty.Length > 0) { item.Members.Add(new PSMemberSet("PSStandardMembers", _DisplayPropertySet)); } else if (ShowExcludeProperty.Length > 0) { item.Members.Add(new PSMemberSet("PSStandardMembers", new PSMemberInfo[] { new PSPropertySet("DefaultDisplayPropertySet", item.Properties.Select(o => o.Name).Where(o => !ShowExcludeProperty.Contains(o))) })); } if (!String.IsNullOrEmpty(TypeName)) { item.TypeNames.Insert(0, TypeName); } WriteObject(item); } }