小编Bla*_*erX的帖子

什么时候不应该使用规则引擎?

我有一个相当不错的使用规则引擎的优点列表,以及使用它们的一些原因,我需要的是你不应该使用规则引擎的原因列表

我到目前为止最好的是:

规则引擎并非真正用于处理工作流或流程执行,也不是用于执行规则的工作流引擎或流程管理工具.

你不应该使用它们的任何其他重要原因?

rule-engine

107
推荐指数
7
解决办法
11万
查看次数

命名约定以区分部分视图与普通视图

部分视图是否有任何非官方的标准命名约定?我见过有人建议用"_"作为前缀,其他人用"Partial"作后缀,我知道这个问题是主观的,但由于没有官方指南,我想知道这里的大多数人用来命名他们的部分观点.也许投票最多的答案将成为标准.

更新:我使用带有Razor的ASP.NET MVC 3作为视图引擎,在以前的版本中你不需要约定,因为你有.ascx扩展名

asp.net-mvc naming-conventions razor

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

我应该在HttpWebResponse上调用Close,即使它在using语句中吗?

我有一些代码,这个代码使用非常多:

using (HttpWebResponse r = _GetHttpWebResponse(uri, body, method, contentType, headers)) {
    /* do something with the response */

    /* call r.Close() explicitly? */
}
Run Code Online (Sandbox Code Playgroud)

代码今天工作正常,但与服务器的连接保持打开很长一段时间.(使用TCPView检查)

Close()显式调用方法有什么好处?是推荐,还是建议不要这样做,为什么?

.net garbage-collection idisposable

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

IDisposable:是否有必要在最后{}检查null?

在明确不使用 "使用" 时在Web上找到的大多数示例中,模式看起来像:

  SqlConnection c = new SqlConnection(@"...");
  try {
    c.Open();
  ...
  } finally {
    if (c != null) //<== check for null
      c.Dispose();
  }
Run Code Online (Sandbox Code Playgroud)

如果您确实使用"using"并查看生成的IL代码,则可以看到它生成了null检查

L_0024: ldloc.1 
L_0025: ldnull 
L_0026: ceq 
L_0028: stloc.s CS$4$0000
L_002a: ldloc.s CS$4$0000
L_002c: brtrue.s L_0035
L_002e: ldloc.1 
L_002f: callvirt instance void [mscorlib]System.IDisposable::Dispose()
L_0034: nop 
L_0035: endfinally 
Run Code Online (Sandbox Code Playgroud)

我理解为什么IL被翻译为检查null(不知道你在using块中做了什么),但是如果你正在使用try..finally并且你可以完全控制IDisposable对象如何在try中使用..最后阻止,你真的需要检查null吗?如果是这样,为什么?

.net c# coding-style idisposable

11
推荐指数
2
解决办法
1066
查看次数

ColdFusion中静态方法的等价物是什么?

在C#中,我创建了静态方法来帮助我执行简单的操作.例如:

public static class StringHelper
{
    public static string Reverse(string input)
    {
        // reverse string
        return reversedInput;
    }
}
Run Code Online (Sandbox Code Playgroud)

然后在控制器中,我会通过简单地使用:

StringHelper.Reverse(input);
Run Code Online (Sandbox Code Playgroud)

现在我正在使用ColdFusion和Model Glue,我想做同样的事情.但是,似乎ColdFusion中没有静态方法的概念.如果我像这样创建一个CFC:

component StringHelper
{
    public string function Reverse(string input)
    {
        // reverse string
        return reversedInput;
    }
}
Run Code Online (Sandbox Code Playgroud)

我是否可以通过StringHelper在控制器中创建实例来调用此方法,如下所示:

component Controller
{
    public void function Reverse()
    {
        var input = event.getValue("input");
        var stringHelper = new StringHelper();
        var reversedString = stringHelper.Reverse(input);
        event.setValue("reversedstring", reversedString);
    }
}
Run Code Online (Sandbox Code Playgroud)

或者在某些地方我可以放置"静态"CFC,框架将在后台创建一个实例,这样我就可以使用它,好像它是静态的,有点像helpers文件夹的工作方式?

c# coldfusion static coldfusion-9

11
推荐指数
2
解决办法
2106
查看次数

导入Azure功能的Python模块

如何导入Python Azure功能的模块?

import requests
Run Code Online (Sandbox Code Playgroud)

导致:

2016-08-16T01:02:02.317 Exception while executing function: Functions.detect_measure. Microsoft.Azure.WebJobs.Script: Traceback (most recent call last):
  File "D:\home\site\wwwroot\detect_measure\run.py", line 1, in <module>
    import requests
ImportError: No module named requests
Run Code Online (Sandbox Code Playgroud)

相关的,可用的模块记录在哪里?

python azure azure-functions

6
推荐指数
2
解决办法
5105
查看次数

从 LINQ 结果中删除 NHibernate

我想知道 nhibernate 中删除方法的最佳用法。

如果你去实体不仅仅是调用 delete 并发送它,但如果不是你需要查询它或编写查询并将其发送到 delete 方法。

我想知道是否可以编写一个 linq 表达式并将其发送给删除。

是否可以对 hql 执行 Linq 转换,然后使用生成的 hql 调用 session.Delete(query)?

我想调用 Session.Delete,并给它一个 linq,这样它就可以知道要删除什么而不选择数据。你知道一个可以将 linq 表达式转换为 hql 的类吗?

linq nhibernate

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

具有UIImage的UITableViewCell,宽度未在初始显示的单元格上更新

我想在UITableViewCell里面动态调整UIImage的宽度,我正在使用故事板来设计UITableViewCell,我只是添加了一个标签和一个图像,属性得到了正确的更新,我甚至加载了值标签中的宽度显示它是正确的值,对于图像,我正在加载我想要重复的背景图像,但是如果我向上和向下滚动图像,图像将不会最初更新宽度如预期所示,这里是cellForRowAtIndexPath的代码,我也尝试将代码放在willDisplayCell方法上,结果相同

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mycustomcell"];
    int r = [[data objectAtIndex:indexPath.row] intValue];
    UIImageView *img = (UIImageView *)[cell viewWithTag:2];
    img.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"some_img" ofType:@"png"]]];
    CGRect frame = img.frame;
    frame.size.width = r*16;
    img.frame = frame;

    int n = img.frame.size.width;
    UILabel *label = (UILabel *)[cell viewWithTag:1];
    label.text = [NSString stringWithFormat:@"custom %d", n];
    [cell setNeedsDisplay];
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

我只是想让它最初工作,因为它在滚动后起作用,想法?

xcode objective-c storyboard uitableview ios

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

有关使用NHibernate CreateSQLQuery的建议是什么?

我的直觉告诉我,高级的NHibernate用户会反对它,我一直在寻找对此的实际分析而没有发现任何东西,我想要解决这些问题的答案:

使用它的优点/缺点是什么?是否有任何性能影响,无论是好的还是坏的(例如,使用它来调用存储过程?)我们应该在哪些场景中使用/避免它?谁应该使用/避免它?

基本上,使用/避免它的原因是什么?为什么?

sql nhibernate

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