小编Jam*_*mie的帖子

是否有可能在Selenium中获取下一个元素

我正在寻找一种在Selenium中获取下一个元素的通用方法.Jquery有一个.next()函数和重载来允许给定的类型,所以我想可能有一个基于JS的解决方案可用于selenium.

鉴于它是如此有用的功能,我想象有人必须已经完成它.

干杯,杰米

selenium selenium-webdriver

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

如何手动调用ValidationAttributes?(DataAnnotations和ModelState)

我们需要在一些逻辑中迭代模型的属性以自动绑定属性,并希望扩展功能以在C#4.0中包含新的数据注释.

目前,我基本上遍历所有ValidationAttribute实例中的每个属性加载并尝试使用Validate/IsValid函数进行验证,但这似乎对我没有用.

作为一个例子,我有一个模型,如:

public class HobbyModel
{
    [Required(AllowEmptyStrings = false, ErrorMessage = "Do not allow empty strings")]
    [DisplayName("Hobby")]
    [DataType(DataType.Text)]
    public string Hobby
    {
        get;
        set;
    }
}
Run Code Online (Sandbox Code Playgroud)

检查属性的代码是:

object[] attributes = propertyInfo.GetCustomAttributes(true);
TypeConverter typeConverter =
TypeDescriptor.GetConverter(typeof(ValidationAttribute));

bool isValid = false;
foreach (object attr in attributes)
{
   ValidationAttribute attrib = attr as ValidationAttribute;

   if (attrib != null)
   {
     attrib.Validate(obj, propertyInfo.Name);
   }
}
Run Code Online (Sandbox Code Playgroud)

我调试了代码,模型确实有3个属性,其中2个是从ValidationAttribute派生的,但是当代码通过Validate函数(带有空值或空值)时,它会按预期抛出异常.

我期待我做一些愚蠢的事情,所以我想知道是否有人使用过这个功能并且可以提供帮助.

先谢谢,杰米

asp.net modelstate validationattribute data-annotations asp.net-mvc-3

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

使用CORS + SOAP + WCF进行HTTPS服务

我正在努力让CORS为我们的SOAP Web服务的新版本(在HTTPS下运行并具有用户名/密码认证)工作,这可以通过JS连接.

目前我在本地(不是跨域)正常工作,但很快它使用不同的域我从WCF Traceviewer得到以下内容.(IIS7中400错误请求)

<ExceptionString>System.Xml.XmlException: The body of the message cannot be read because it is empty.</ExceptionString>
Run Code Online (Sandbox Code Playgroud)

它似乎甚至没有到达我的消息检查器运行的部分来添加适当的CORS头.

有没有人经历过这个或者设法让CORS在HTTPS SOAP服务下工作?

我很感激你能给出的任何建议.

干杯,杰米

javascript wcf soap cross-domain cors

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

如何获取 WIX 3.6 中编辑框的上下文菜单?

我昨天正在查看我的一些工作安装程序代码报告的错误,发现右键单击不会为我们的任何安装程序打开上下文菜单。

上下文菜单显示为密码框,所以我的粘贴认为这是我在浏览文档时错过的设置,但我在谷歌上没有看到任何内容。

这是一个错误吗?缺少设置或设计功能?

代码非常简单,如下所示:

(工作案例:密码箱)

 <Control Id="Label2" Type="Text" X="15" Y="123" Width="85" Height="18" Transparent="yes" Text="Password:" />
 <Control Id="Edit2" Type="Text" Password="yes" X="100" Y="120" Width="235" Height="18" Property="PASSWORD" Text="[PASSWORD]" ToolTip="The password for the activation service to register the application." />
Run Code Online (Sandbox Code Playgroud)

(失败案例:编辑或文本框)

  <Control Id="Label1" Type="Text" X="15" Y="103" Width="80" Height="18" Transparent="yes" Text="Username:" />
  <Control Id="Edit1" Type="Edit" X="100" Y="100" Width="235" Height="18" Property="ACTIVATIONUSERNAME" Text="[ACTIVATIONUSERNAME]" ToolTip="The username for the activation service to register the application." />
Run Code Online (Sandbox Code Playgroud)

干杯,J

PS 我检查了 WIX 3.5,似乎发生了同样的问题。

windows-installer contextmenu wix wix3.5 wix3.6

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

如何在安装程序退出时执行多个启动条件

我已经设法让WIX在退出时启动我的应用程序,但不知道如何使用WixShellExecTarget属性安排两个自定义操作.

一个CA是启动应用程序,另一个是基于来自另一个CA的URL的网页.如果选中相应的复选框,则会启动这些选项.

<!-- Custom action for executing app -->
    <Property Id="WixShellExecTarget" Value="[#Application.exe]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

    <!-- Custom action for executing Webbrowser -->

    <Property Id="???" Value="[CONFIGWIZARDURL]" />
    <CustomAction Id="LaunchConfigWizard" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
Run Code Online (Sandbox Code Playgroud)

任何帮助你可以让我让这个工作将不胜感激.

干杯,杰米

[编辑]我已经尝试了下面的建议,但我没有为第二个动作设置合适的值.它没有像我建议的那样去www.google.com:

<Publish Dialog="MyExitDialog" Control="Finish" Event="DoAction" Value="SetExec1"><![CDATA[NOT Installed]]></Publish>
        <Publish Dialog="MyExitDialog" Control="Finish" Event="DoAction" Value="DoExec"><![CDATA[LAUNCHCAPTURE = "1" AND NOT Installed]]></Publish>

        <Publish Dialog="MyExitDialog" Control="Finish" Event="DoAction" Value="SetExec2"><![CDATA[NOT Installed]]></Publish>
        <Publish Dialog="MyExitDialog" Control="Finish" Event="DoAction" Value="DoExec"><![CDATA[LAUNCHCONFIGWIZARD = "1" AND NOT Installed]]></Publish>



Property(S): LAUNCHCONFIGWIZARD = 1
MSI (s) (5C:DC) …
Run Code Online (Sandbox Code Playgroud)

installer custom-action wix shell-exec wix3.5

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

C#'泛型问题,如何通过Func传递输入和输出

private static K ExecuteStoredProcedure<K>(string connectionString, string storedProcedure, SqlParameter[] parameters, Func<I, K> readFunction)
Run Code Online (Sandbox Code Playgroud)

示例用法如下所示:

 return ExecuteStoredProcedure<SqlDataReader, Dictionary<string, string>>(
     connectionString, 
     "uspSearchStatisticsSelectByTokenPerDayGroupByDate", 
     parameters, 
     (reader) =>
     {
         reader.Read();
         int readCount = reader.FieldCount;

         Dictionary<string, string> results = new Dictionary<string, string>();
         results.Add("FailedRequests", Convert.ToString(reader[5]));
         results.Add("TotalRequests", Convert.ToString(reader[4]));
         results.Add("AverageResponseTime", Convert.ToString(reader[3]));

         return results;
     }
 );
Run Code Online (Sandbox Code Playgroud)

编译器回来了

错误520无法找到类型或命名空间名称"我"(您是否缺少using指令或程序集引用?)

但我认为它应该可以参考吗?

更新:我试图寻找太通用的东西而不是真的需要它.

我跟着以下...... private static K ExecuteStoredProcedure<K>(string connectionString, string storedProcedure, SqlParameter[] parameters, Func<SqlDataReader, K> readFunction)

c# generics func

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