代表确实是您所需要的。在这种情况下,由于所有操作都在function fillAnyForm(selectors,values) {
if(!isArray(selectors)) throw 'Parameter "selectors" must be an array'
if(!isArray(values)) throw 'Parameter "values" must be an array'
nPromises = Math.min(selectors.length,values.length)
promises = []
for(let i = 0; i < nPromises; i++) {
promises.push(new Promise(/* This is the part I don't get */))
}
return Promise.all(promises);
}
对象上操作并返回内容,因此您需要一个Car
,其中Func<Car,Something>
是Something
的类型,而其他则返回:
Horn
您可以编写两个专门的操作,如下所示:
private void PerformOperation(Func<Car,Something> operation)
{
var response = operation.Invoke(_car);
if(response.Status != 0)
{
throw new Exception("Operation failed!");
}
}
,
应该是
private void PerformOperation(Func<int> operation)
您定义
public void TurnOnHazarLights() => PerformOperation(()=>_car.ToggleHazards(true));
public void SoundHorn() => PerformOperation(() => m_car.SoundHorn(100))
或将替换为您的Response类的类型。
,
也许我正在监督某些事情,但是为什么这样不起作用:
<div class="container holidayContent">
<div class="row">
<h1>Holidays</h1>
</div>
<div class="row">
<?php
$sql = "SELECT holiday.*,users.* FROM holiday INNER JOIN users ON holiday.user_id = users.user_id WHERE users.user_id = '" . $_SESSION['userId'] . "'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
?>
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Name</th>
<th>Start Date</th>
<th>End Date</th>
<th>Reason</th>
<th>Validated</th>
</tr>
</thead>
<tbody>
<?php while ($row = mysqli_fetch_array($result)) { ?>
<tr>
<td><?php echo $row['first_name'] . ' ' . $row['last_name']; ?></td>
<td><?php echo $row['start_date']; ?></td>
<td><?php echo $row['end_date']; ?></td>
<td><?php echo $row['reason']; ?></td>
<td><?php if ($row['validated'] == 0) {
echo '<a><i class="fas fa-check-circle"></i></a>';
echo '<a><i class="fas fa-times-circle"></i></a>';
} else if ($row['validated'] == 1) {
echo '<i class="fas fa-check-circle"></i>';
} else {
echo '<i class="fas fa-times-circle"></i>';
} ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } else {
echo "You have not asked for any days off.";
}
$conn->close();
?>
</div>
</div>
然后您将通过
进行调用
private void PerformOperation(Func<Response> operation)
{
var response = operation();
if(response.Status != 0)
{
throw new Exception("Operation failed!");
}
}
本文链接:https://www.f2er.com/3116954.html