我有一个方法调用SQLServer函数对表执行自由文本搜索.该函数有时会在第一次调用时导致SQLException:"全文查询字符串的单词分解超时".所以我通常想重试该请求,因为它会在后续请求中成功.构造重试逻辑的好方法是什么.目前我有以下内容:
var retryCount = 0;
var results = new List<UserSummaryDto>();
using (var ctx = new UsersDataContext(ConfigurationManager.ConnectionStrings[CONNECTION_STRING_KEY].ConnectionString))
{
for (; ; )
{
try
{
results = ctx.SearchPhoneList(value, maxRows)
.Select(user => user.ToDto())
.ToList();
break;
}
catch (SqlException)
{
retryCount++;
if (retryCount > MAX_RETRY) throw;
}
}
}
return results;
Run Code Online (Sandbox Code Playgroud) 假设我有:
var context = document.getElementById('test').getContext('2d');
// Background
context.fillStyle = '#000';
context.fillRect(0,0,300,300);
// 'P'
context.beginPath();
context.moveTo(90,89);
context.lineTo(161,89);
context.quadraticCurveTo(200,89,200,127);
context.quadraticCurveTo(200,166,148,166);
context.lineTo(115,166);
context.lineTo(108,210);
context.lineTo(69,210);
context.lineTo(90,89);
context.fillStyle = "#eee";
context.fill();
context.closePath();
context.globalCompositeOperation = 'destination-out';
// 'P' hole
context.beginPath();
context.moveTo(124,117);
context.lineTo(146,117);
context.quadraticCurveTo(160,117,160,127);
context.quadraticCurveTo(160,145,146,145);
context.lineTo(120,145);
context.lineTo(124,117);
context.fillStyle = '#ffffff';
context.fill();
context.closePath();
Run Code Online (Sandbox Code Playgroud)
这是有效的,除非您可以看到"洞"不是剪辑,因此如果背景不是实心,您根本无法设置孔的"填充"颜色以匹配背景.
因此我需要修剪这个洞.然而,当我这样做时,显示的'P'的唯一部分是由剪辑'孔'限定的部分.我需要反过来.我需要'P'来显示,但是用"洞"剪切部分,这样任何背景都会显示出来.
这是我得到的,但不完全在那里:
var context = document.getElementById('test').getContext('2d');
// Background
context.fillStyle = '#000';
context.fillRect(0,0,300,300);
// 'P' hole clip
context.beginPath();
context.moveTo(124,117);
context.lineTo(146,117);
context.quadraticCurveTo(160,117,160,127);
context.quadraticCurveTo(160,145,146,145);
context.lineTo(120,145);
context.lineTo(124,117);
context.clip();
context.closePath();
// 'P'
context.beginPath();
context.moveTo(90,89);
context.lineTo(161,89);
context.quadraticCurveTo(200,89,200,127);
context.quadraticCurveTo(200,166,148,166);
context.lineTo(115,166);
context.lineTo(108,210); …Run Code Online (Sandbox Code Playgroud) 我在Designer中显示组件时遇到问题.
我发现了设计师不喜欢的"坏"代码.
现在,问题是我不能仅仅使用预处理器指令来"评论"它的设计时间.
现在,我尝试了(对于VB.NET)以下内容
#If Not Debug Then
Private Sub myWpfComponent_ItsEvent(sender, args) Handles myWpfComponent.ItsEvent
...
#End If
Run Code Online (Sandbox Code Playgroud)
这...工作,现在它在设计师中显示没有问题.
现在的问题是我恐怕无法正确调试这个组件.
所以,我正在寻找一种解决方法
#If Not DESIGN_TIME Then
#End If
Run Code Online (Sandbox Code Playgroud)
有类似的东西吗?
我的pom中有以下exec任务:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/src/test/javascript/EnvJasmine/bin/run_all_tests.sh</executable>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
我跑的时候效果很好
mvn exec:exec
Run Code Online (Sandbox Code Playgroud)
但我也希望它在执行时运行
mvn test
Run Code Online (Sandbox Code Playgroud)
有人能帮我一下吗?
我已经为我的config.yml文件添加了一个设置:
app.config:
contact_email: somebody@gmail.com
...
Run Code Online (Sandbox Code Playgroud)
对于我的生活,我无法弄清楚如何将其读入变量.我在我的一个控制器中尝试过这样的东西:
$recipient =
$this->container->getParameter('contact_email');
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误说:
必须定义参数"contact_email".
我已经清除了我的缓存,我也在Symfony2重新加载的站点文档中查看了所有内容,但我无法找到如何执行此操作.
可能现在太累了,无法弄明白这一点.有人能帮忙吗?
我有params[:month,:day,:year],我需要将它们转换成DateTime我可以放在隐藏输入中的那个.
在Rails 3中执行此操作的最佳方法是什么?
有没有办法,使用XAML,根据其中一个单元格的内容动态设置行的背景?
谢谢,
菲尔
如何查明子类是否覆盖了某个方法?
例如,
public class Test {
static public class B {
public String m() {return "From B";};
}
static public class B1 extends B {
}
static public class B2 extends B {
public String m() {return "from B2";};
}
/**
* @param args
* @throws FileNotFoundException
*/
public static void main(String[] args) {
B b1 = new B1();
System.out.println("b1 = " + b1.m());
B b2 = new B2();
System.out.println("b1 = " + b2.m());
}
}
Run Code Online (Sandbox Code Playgroud)
给定B的一个实例,我怎么知道任何派生类是否有像B2这样的重写方法m()?
更新:我的问题不明确.实际上,我试图在不诉诸反思的情况下询问是否可行.这种检查是在一个紧凑的循环中完成的,它用于性能破解以节省一些CPU周期.
我正在尝试使用BeanUtils与类似于以下内容的Java bean进行交互:
public class Bean {
private List<Integer> prices = new LinkedList<Integer>();
public List<Integer> getPrices() {
return prices;
}
}
Run Code Online (Sandbox Code Playgroud)
根据BeanUtils文档,BeanUtils支持Lists的索引属性:
作为JavaBeans规范的扩展,BeanUtils包会考虑其基础数据类型为java.util.List(或List的实现)的任何属性.
但是,假设我尝试执行以下操作:
Bean bean = new Bean();
// Add nulls to make the list the correct size
bean.getPrices().add(null);
bean.getPrices().add(null);
BeanUtils.setProperty(bean, "prices[0]", 123);
PropertyUtils.setProperty(bean, "prices[1]", 456);
System.out.println("prices[0] = " + BeanUtils.getProperty(bean, "prices[0]"));
System.out.println("prices[1] = " + BeanUtils.getProperty(bean, "prices[1]"));
Run Code Online (Sandbox Code Playgroud)
输出是:
prices[0] = null
prices[1] = 456
Run Code Online (Sandbox Code Playgroud)
为什么BeanUtils.setProperty()无法设置索引属性,PropertyUtils.setProperty()可以吗?BeanUtils不支持Lists中对象的类型转换吗?
java ×4
wpf ×2
.net ×1
c# ×1
canvas ×1
clip ×1
exec ×1
html5 ×1
inheritance ×1
javabeans ×1
jvisualvm ×1
linq ×1
maven ×1
methods ×1
overriding ×1
preprocessor ×1
ruby ×1
sql ×1
symfony ×1
testing ×1
wpfdatagrid ×1
wpftoolkit ×1
xaml ×1