问题列表 - 第29871页

在DataContract中设置默认值?

如何为DataMember设置默认值,例如下面显示的值:

我想默认设置ScanDevice ="XeroxScan"

    [DataMember]
    public string ScanDevice { get; set; }
Run Code Online (Sandbox Code Playgroud)

c# wcf datacontractserializer

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

如何使用IVsBuildPropertyStorage添加MSBuild导入?

我正在尝试以编程方式将导入任务添加到.csproj文件,但我不想使用Microsoft.Build.BuildEngine对象来执行此操作,因为VS将弹出有关正在修改的项目文件的警告视觉工作室.

我已经看过几页[1] [2]建议IVsBuildPropertyStorage接口让我访问.csproj文件的MSBuild部分,但是我无法弄清楚如何做到这一点,或者它是否真的可能真的.看起来我需要指定我想要访问的属性的名称,但我不知道如何解决这个问题.为"导入"属性调用GetPropertyValue()不会返回已设置的项目文件的任何内容,我希望最终结果如何显示:

EnvDTE.Project proj = ...;
var sol = Package.GetGlobalService(typeof(VsSolution)) as IVsSolution;
IVsHierarchy hier;
sol.GetProjectOfUniqueName(p.UniqueName, out hier);
var storage = hier as IVsBuildPropertyStorage;
string val;
storage.GetPropertyValue("Import", String.Empty,
                         (uint)_PersistStorageType.PST_PROJECT_FILE, out val);
// val is null
Run Code Online (Sandbox Code Playgroud)

[1] https://mpfproj.svn.codeplex.com/svn/9.0/Tests/UnitTests/ProjectTest.cs
[2] http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/e1983591-120a-4a2f-A910-e596dd625e68

谢谢.我很感激我能得到的任何建议.

msbuild msbuild-task visual-studio

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

列表的直接孩子

一个简单的问题..什么是JAVASCRIPT语句来获取LIST的直接孩子?我试过了:

document.getElementById(id).getElementsByTagName('li');
Run Code Online (Sandbox Code Playgroud)

这给了我所有的子节点.

javascript

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

C#中"As"关键字的重点是什么?

来自文档:

as运算符就像一个转换器,除了它在转换失败时产生null而不是引发异常.更正式地说,表达形式:

   expression as type
Run Code Online (Sandbox Code Playgroud)

相当于:

  expression is type ? (type)expression : (type) null
Run Code Online (Sandbox Code Playgroud)

除了表达式只评估一次.

那你为什么不选择这样或那样做呢?为什么有两个铸造系统?

c# keyword

55
推荐指数
4
解决办法
2万
查看次数

RDFa产品的内容实施

我是噩梦中的膝盖深处,这是产品信息的RDFa实施,如果有人能提供一些见解我很好奇.

谷歌表示,不是为了向机器提供数据而隐藏信息,除非它是特定于机器的信息.为了提供这些数据,我找不到任何有关空元素的信息.

如果你看一下商业的GoodRelations RDFa生成器,你会得到一堆嵌套的div,你被告知放在你的项目页面的底部.我将使用我最喜欢的网站之一:

<div xmlns="http://www.w3.org/1999/xhtml"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
  xmlns:gr="http://purl.org/goodrelations/v1#"
  xmlns:foaf="http://xmlns.com/foaf/0.1/">

  <div typeof="gr:Offering" about="#offering">
    <div rev="gr:offers" resource="#company"></div>
    <div property="rdfs:label" content="Alpinestars S-MX Plus Racing Boots" xml:lang="en"></div>
    <div property="rdfs:comment" content="Alpinestars’ S-MX Plus racing boot raises performance and safety to new and unmatched levels with its innovative design, structural protection and comfort." xml:lang="en"></div>
    <div property="gr:hasEAN_UCC-13" content="0000000000000" datatype="xsd:string"></div>
    <div rel="foaf:depiction" resource="http://www.motorcycle-superstore.com/ProductImages/300/g17268.jpg"></div>
    <div rel="gr:hasBusinessFunction" resource="http://purl.org/goodrelations/v1#Sell"></div>
    <div rel="gr:hasPriceSpecification">
      <div typeof="gr:UnitPriceSpecification">
        <div property="gr:hasCurrency" content="USD" datatype="xsd:string"></div>
        <div property="gr:hasCurrencyValue" content="349.95" datatype="xsd:float"></div>
        <div property="gr:hasUnitOfMeasurement" content="C62" datatype="xsd:string"></div>
      </div>
    </div>
    <div rel="gr:acceptedPaymentMethods" …
Run Code Online (Sandbox Code Playgroud)

xml rdf xml-namespaces rdfa

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

Python:索引以制表符分隔的文件

我有一个以制表符分隔的文本文件,如下所示:

1_0 NP_045689 100.00 279 0 0 18 296 18 296 3e-156 539

1_0 NP_045688 54.83 259 108 6 45 296 17 273 2e-61 224

我需要解析特定的列,例如第2列.

我试过下面的代码:

z = open('output.blast', 'r')
for line in z.readlines():
    for col in line:
        print col[1]
z.close()
Run Code Online (Sandbox Code Playgroud)

但我得到索引超出范围错误.

python indexing

2
推荐指数
2
解决办法
4万
查看次数

使用JQuery折叠DIV

我有一个页面上有两个div.此页面如下所示:

<div id="waitDiv">
  <div id="waitText">Analyzing...</div>
  <img src="wait.gif" />
</div>

<div id="finishedDiv" style="visibility:collapse;">
  <div>You may now proceed</div>
  <div>Please remember that....</div>
</div>

<script type="text/javascript">
  $(document).ready(function () {
    var progressTimer = setTimeout("updateState()", 5000);
  });

  var count = 1;
  function updateState() {
    if (count <= 5) {
      var progressTimer = setTimeout("updateState()", 5000);
      count = count + 1;
    }
    else {
      $("#waitDiv").css("visibility", "collapse");
      $("#finishedDiv").css("visibility", "visible");
    }
  }
</script>
Run Code Online (Sandbox Code Playgroud)

基本上,当页面加载时,我需要它等待一段时间.然后,我需要在时间结束时在finishedDiv中显示信息.目前,finishedDiv确实显示了.但是,它显示在waitDiv下面.waitDiv变得不可见.但是,我需要将finishedDiv定位在waitDiv所在的位置.为什么finishDiv出现在waitDiv下面,即使我崩溃了?

谢谢!

css jquery

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

导入的文件无法在OCUnit中识别

我正在使用XCode 3.2.3和iOS 4.0上的OCUnit在我的iPhone应用程序上进行单元测试.我已成功设置我的测试环境以适当地传递和失败基本测试,但是当我导入自己的文件时(在这种情况下,"UserAccount.h",它无法编译并告诉我:

"_OBJC_CLASS _ $ _ UserAccount",引自:

然后它说"未找到符号".这让我感到某种链接器错误,但我不知道发生了什么.我已多次建造和清理所有目标,但无济于事.这是我的测试代码:

#import "SomeTestCase.h"
#import "UserAccount.h"

@implementation SomeTestCase

 - (void)testUserAccount
 {
 // UserAccount.m //

 UserAccount *testAccount = [[UserAccount alloc] initWithUsername:@"" password:@"" deviceToken:@""];
 [testAccount registerNew];
 NSLog(@"USERID = %@", testAccount.userID);
 STAssertEquals([testAccount login], NO, @"Failure: Login should fail with blank username and password."); // should fail with no username or password

 UserAccount *testAccount2 = [[UserAccount alloc] initWithUsername:@"user" password:@"" deviceToken:@""]; 
 STAssertEquals([testAccount2 login], NO, @"Failure: Login should fail with blank password.");// should fail with no password

 UserAccount *testAccount3 …
Run Code Online (Sandbox Code Playgroud)

iphone xcode linker unit-testing ocunit

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

在rails控制器中,如何防止双重提交(当用户双提交按钮或按两次输入时)?

好吧,一切都在标题中,但我会解释一下:-)

我的rails应用程序包含许多表单(Ajaxified或不Ajaxified).

为了防止用户提交两次或更多的表格,我使用Javascript.

有一个Ajaxified表单的场景:

  • 用户提交表格(clic或enter)
  • javascript禁用提交按钮
  • rails控制器执行操作(如Soap请求或DB中的插入)
  • rails控制器更新页面并在必要时启用提交按钮(如果有错误)

现在我想添加服务器端代码,以便在用户绕过javascript时保持真正干净.

有什么建议?

javascript forms controller ruby-on-rails double-submit-problem

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

关于如何在代码中引用web.config键名的想法

当您的web.config或app.config文件具有appsettings条目时,在代码文件中引用其键的最佳方法是什么?

我曾与之合作的开发人员对此有不同的看法.有人说硬编码字符串,而其他人则建议应该有一个包含字符串常量的文件,在你的代码中,你使用常量作为appsettings键.

我有兴趣听取其他意见.你是做什么?为什么它是最好的?

asp.net web-config

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