mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
This reverts commit 190c99a416.
This commit is contained in:
+3
@@ -1157,6 +1157,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
switch (content)
|
||||
{
|
||||
case FormObject form:
|
||||
SetRequestContent(request, form.Fields);
|
||||
break;
|
||||
case IDictionary dictionary when request.Method != HttpMethod.Get:
|
||||
SetRequestContent(request, dictionary);
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// FormObject used in HtmlWebResponseObject.
|
||||
/// </summary>
|
||||
public class FormObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id property.
|
||||
/// </summary>
|
||||
public string Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Method property.
|
||||
/// </summary>
|
||||
public string Method { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Action property.
|
||||
/// </summary>
|
||||
public string Action { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Fields property.
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Fields { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FormObject"/> class.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="method"></param>
|
||||
/// <param name="action"></param>
|
||||
public FormObject(string id, string method, string action)
|
||||
{
|
||||
Id = id;
|
||||
Method = method;
|
||||
Action = action;
|
||||
Fields = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
internal void AddField(string key, string value)
|
||||
{
|
||||
if (key is not null && !Fields.TryGetValue(key, out string test))
|
||||
{
|
||||
Fields[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// FormObjectCollection used in HtmlWebResponseObject.
|
||||
/// </summary>
|
||||
public class FormObjectCollection : Collection<FormObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the FormObject from the key.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public FormObject this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
FormObject form = null;
|
||||
foreach (FormObject f in this)
|
||||
{
|
||||
if (string.Equals(key, f.Id, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
form = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return form;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user