我正在尝试使用 save 方法保存一个 xml 对象。我收到错误:
为“保存”和参数计数找到了多个不明确的重载:“1”。
Function Save-File($config, $fileLocation){
#saves to file
$config.Save($fileLocation)
}
Run Code Online (Sandbox Code Playgroud)
我知道通过只运行一个 save 程序运行没有错误。所以我相信该方法的多次调用导致了这个问题,但我不熟悉参数。
我能做些什么来安抚 Powershell 控制台,它在 Powershell ISE 中运行,但我不知道现在在哪里看。
感谢阅读。如果您有任何问题,请告诉我,我会尽力提供正确的信息。
我不能为我的生活记住如何做到这一点.该程序打开一个文件,然后读取该文件.我想要做的就是打印刚读过的内容.
int main(int argc, char *argv[])
{
char memory[1000]; //declare memory buffer size
int fd = 0;
int count = 1000;
if ((fd = open(argv[1], O_RDONLY)) == -1)
{
fprintf(stderr, "Cannot open.\n");
exit(1);
}
read(fd, memory, count);
//printf the buffered memory contents
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我刚开始使用Powershell,我试图拆分一个保存为字符串的连接字符串.我尝试过正则表达式和数组拆分但是因为我正在学习,所以我想问一下大家的入门级想法.
下面是一个连接字符串示例,我试图将每个关键区域分配给变量.
@{connectionString=Data Source=database;Initial Catalog=catalog;User ID=userid;Password=password}
Run Code Online (Sandbox Code Playgroud)
理想情况下,我希望每个值都可用于变量.
谢谢阅读.
你好我今天的问题是细分并弄清楚如何实际编码我已设法完成步骤(1)和(2)的算法的LOWER TANGENT部分,但我现在仍然坚持步骤(3).
划分和征服凸出的船体
船体(S):
(1)如果| S | <= 3,然后在O(1)时间内通过强力计算凸包并返回.
(2)否则,将点集S划分为两组A和B,其中A由具有最低x坐标的一半点组成,B由具有最高x坐标的一半点组成.
(3)递归计算HA = Hull(A)和HB = Hull(B).
(4)通过计算HA和HB的上下切线并丢弃位于这两个切线之间的所有点,将两个船体合并成一个共同的凸包H.
http://www.cs.wustl.edu/~pless/506/l3_1.gif
寻找下切线
LowerTangent(HA; HB):
(1)让a成为HA最右边的一点.
(2)设b是HB的最左边.
(3)虽然ab不是HA和HB的下切线
(a)虽然ab不是HA的下切线,但a = a - 1(顺时针方向移动).
(b)虽然ab不是HB的下切线,但是b = b + 1(逆时针方向移动b).
(4)返回ab.
引用自:http://www.cs.wustl.edu/~pless/506/l3.html 这个解释是描述我的问题的最佳解释.
Lexisort和convexHull的功能尚未包括在内,因为它们正在工作,DC船体算法已被包含在内以提供上下文.
我目前的代码:
public static int [][] dcHull(int [][]merged){
if(merged.length <= 3)
return convexHull(merged);
else {
lexiSort(merged);
//split(P, A, B);
//SPLIT
double p = merged.length;
int A;
int B;
if (p%2 == 0){//EVEN
A = (int) (p/2);
B = (int) (p/2);
} …Run Code Online (Sandbox Code Playgroud) 我有一个XML配置作为xml对象加载到我的脚本中$appConfig.我试图用我自己的字符串替换连接字符串值.这是我到目前为止找到的目标字符串:
$appConfig.configuration.connectionStrings.add |
? {$_.name -eq $dbName} |
select connectionString
Run Code Online (Sandbox Code Playgroud)
我基本上想要类似于此的东西:
$appConfig.configuration.connectionStrings.add |
? {$_.name -eq $dbName} |
select connectionString = $updatedConnectionString
Run Code Online (Sandbox Code Playgroud)
我很确定我需要创建一个变量并用它来填充它$appConfig但每次我尝试时我最终都会使用另一个XML对象而不是$appConfig按预期编辑目标对象.我将$appConfig其写回原始文件位置并完成编辑.我似乎无法在这里获得正确的语法.
我的XML示例与字符串相关:
<configuration>
<connectionStrings>
<add name="db" connectionString="Data Source=(local);Initial Catalog=MyDB;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="dbFiles" connectionString="Data Source=(local);Initial Catalog=MyDB;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="dbReporting" connectionString="Data Source=(local);Initial Catalog=MyDB;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="Logging" connectionString="Data Source=(local);Initial Catalog=MyDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)