问题列表 - 第17305页

是否有可能(以及如何)在C#中在运行时将ConnectionString添加到app.config?

我有一个控制台应用程序,它将connectionstring作为参数.我必须在app.config中设置一个名为'ConnectionString'的ConnectionString,并将给定的参数设置为sql connectionstring.

谢谢答案.借助我的链接,我得到了这个:

var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionStringSettings = new ConnectionStringSettings("ConnectionString",_ arguments ["connectionString"],"System.Data.SqlClient"); config.ConnectionStrings.ConnectionStrings.Add(connectionStringSettings); config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection( "的ConnectionStrings");

c# connection-string app-config

5
推荐指数
2
解决办法
7561
查看次数

在F#中BigInteger中是否有Pow的替代品?

当我的编译器告诉我时,我在F#中使用了BigInteger类的Pow函数:

不推荐使用此构造.此成员已被删除,以确保此类型与.NET 4.0类型System.Numerics.BigInteger二进制兼容

我觉得很公平,但我没有立即找到替代品.

有吗?我们应该只使用自己的Pow功能吗?并且(如何)它将在NET4.0中被替换?

f# biginteger pow

6
推荐指数
1
解决办法
1009
查看次数

JUnit:暂停用户输入

我正在学习JUnit.由于我的应用程序包含图形输出,我希望能够根据我所看到的情况来观察输出并手动传递或失败测试.它应该等我一段时间,如果它超时则失败.

有没有办法在JUnit(或其扩展)中执行此操作,或者我应该在输出上抛出一个对话框和assertTrue?看起来它可能是现有解决方案的常见问题.

编辑:如果我不应该使用JUnit,我应该使用什么?我想经常手动验证构建,并自动进行单元测试,如果两个测试框架相处得很好.

java testing junit

3
推荐指数
1
解决办法
2887
查看次数

我可以更改ZipArchive的压缩级别吗?

是否可以更改类使用的压缩级别和/或方法ZipArchive

php zip

17
推荐指数
3
解决办法
1万
查看次数

你如何在VB.NET的HTTPCookie中使用Ampersand?

我有一个cookie保存给用户如下...

Dim searchCookie As HttpCookie = New HttpCookie("SearchCriteria")
searchCookie.Item("SearchText") = FullSearchCriteria.SearchText
searchCookie.Item("SearchType") = FullSearchCriteria.SearchType
Run Code Online (Sandbox Code Playgroud)

SearchText存储他们在上一页中输入的值.我们观察到cookie中是否存在&符号(例如Tyne&Wear),然后cookie不保存后续值(SearchType).

会发生什么是cookie输出如下:

SearchText=Tyne &
Run Code Online (Sandbox Code Playgroud)

很明显,&符号令人困惑.有没有办法防止这种情况发生?

vb.net cookies ampersand

1
推荐指数
1
解决办法
1244
查看次数

如何在RESTful API中使用OpenID?

我正在使用RESTful API构建基于Pylons的Web应用程序,该API目前缺少任何身份验证.所以我要实现它,为了避免存储用户密码的所有麻烦和谨慎,我想使用OpenID进行身份验证.最好的方法是什么?这两件事是否兼容?是否存在使用OpenID的现有REST API,我可以从中获取灵感?

openid api rest pylons

31
推荐指数
1
解决办法
1万
查看次数

WPF - 无法使故事板影响另一个本地资源

我已经将Transformation和Storyboard设置为本地资源,但是当我从按钮触发故事板时,我收到以下错误:

{"'WorldTranslation'名称在'System.Windows.Controls.Button'的名称范围内找不到."}

有人能指出我正确的方向吗?

<Window.Resources>

    <Transform3DGroup x:Key="WorldTranslation">
        <RotateTransform3D>
            <RotateTransform3D.Rotation>
                <AxisAngleRotation3D x:Name="myAngleRotation" Axis="0,1,0" Angle="0" />
            </RotateTransform3D.Rotation>
        </RotateTransform3D>
    </Transform3DGroup>

    <Storyboard x:Key="MyStoryboard">
        <DoubleAnimation
            Storyboard.TargetName="WorldTranslation"
        Storyboard.TargetProperty="(Transform3DGroup).(RotateTransform3D).(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)"
        From="0"
        To="360"
        Duration="0:0:1"   
       />
    </Storyboard>

</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

继续按下按钮xaml ...

<Button Height="20" Width="100">
   <Button.Content>Blah</Button.Content>
       <Button.Triggers>
          <EventTrigger RoutedEvent="Button.Click">
               <EventTrigger.Actions>
                   <BeginStoryboard Storyboard="{StaticResource MyStoryboard}" >

                    </BeginStoryboard>
                </EventTrigger.Actions>
          </EventTrigger>
       </Button.Triggers>
  </Button>
Run Code Online (Sandbox Code Playgroud)

wpf animation storyboard

1
推荐指数
1
解决办法
4759
查看次数

为什么这样做?方法重载+方法重写+多态

在以下代码中:

public abstract class MyClass
{
public abstract bool MyMethod(
        Database database,
        AssetDetails asset,
        ref string errorMessage);
}

public sealed class MySubClass : MyClass
{
    public override bool MyMethod(
        Database database,
        AssetDetails asset,
        ref string errorMessage)
    {
        return MyMethod(database, asset, ref errorMessage);
    }

    public bool MyMethod(
        Database database,
        AssetBase asset,
        ref string errorMessage)
    {
    // work is done here
}
}
Run Code Online (Sandbox Code Playgroud)

其中AssetDetails是AssetBase的子类.

为什么第一个MyMethod在传递AssetDetails时会在运行时调用第二个,而不是陷入递归的无限循环?

c# polymorphism overriding overloading

12
推荐指数
2
解决办法
2946
查看次数

使用iText将外部图像添加到PDF

我无法弄清楚如何使用iText将外部图像(由URL引用)添加到PDF.这种事可能吗?

7.1.5中的PDF规范说明您应该能够通过使用URL规范通过URL引用PDF.这是我到目前为止所得到的:

PdfFileSpecification pdfSpec = 
    PdfFileSpecification.url(writer, "http://www.someurl.com/test.jpg");

StringBufferInputStream sbis = new StringBufferInputStream("");   
PdfStream dict = new PdfStream(sbis, writer);
dict.put(PdfName.FILTER, PdfName.DCTDECODE)
dict.put(PdfName.TYPE, PdfName.XOBJECT);
dict.put(PdfName.SUBTYPE, PdfName.IMAGE);
dict.put(PdfName.WIDTH, new PdfNumber(100));
dict.put(PdfName.HEIGHT, new PdfNumber(100));
dict.put(PdfName.BITSPERCOMPONENT, new PdfNumber(8));
dict.put(PdfName.LENGTH, new PdfNumber(0));
dict.put(PdfName.F, pdfSpec);

PdfIndirectObject img = writer.addToBody(dict);
Run Code Online (Sandbox Code Playgroud)

我知道我仍然需要确保添加色彩空间和东西,但我现在主要关心的是将这个图像放入文档的正文中.我无法弄清楚如何做到这一点......似乎我无法获得对PdfPage或资源字典或任何东西的引用.这可能使用iText吗?

作为旁注,如果在视图尝试加载图像时我将收到安全警告,则此练习无效.有谁知道是否是这种情况?

pdf image itext

7
推荐指数
1
解决办法
8697
查看次数

运算符/重载

出于学习目的,我正在用C++创建大整数类.有2个文件:

big_int.h

#ifndef BIG_INT_H
#define BIG_INT_H

#include 

class big_int
{
public:
    big_int(void);
    big_int(char*);
    big_int(QString);

    ~big_int();

    big_int operator+(big_int);
    big_int operator-(big_int);
    big_int operator*(big_int);
    big_int operator/(big_int);
};

#endif // BIG_INT_H
Run Code Online (Sandbox Code Playgroud)


big_int.cpp


#include "big_int.h"

big_int::big_int()
{
}

big_int::big_int(QString str)
{
}

big_int::~big_int()
{
}

big_int operator+(big_int b)
{
    return big_int();
}

big_int operator-(big_int b)
{
    return big_int();
}

big_int operator*(big_int b)
{
    return big_int();
}

big_int operator/(big_int)
{
    return big_int();
}
Run Code Online (Sandbox Code Playgroud)

Qt Creator返回:C:/ Documents and Settings/Admin/My Documents/calculator_1_0/big_int.cpp:31:error:big_int operator /(big_int)必须带两个参数.但是operator /只需要1个参数.怎么了?

c++ operator-overloading

0
推荐指数
1
解决办法
822
查看次数