小编des*_*man的帖子

"不包含"动态lambda表达式

下面的代码执行"包含"表达式:

private static Expression<Func<T, bool>> Contains<T>(string property, string value)
{
    var obj = Expression.Parameter(typeof(T), "obj");
    var objProperty = Expression.PropertyOrField(obj, property);
    var contains = Expression.Call(objProperty, "Contains", null, Expression.Constant(value, typeof(string)));
    var lambda = Expression.Lambda<Func<T, bool>>(contains, obj);
    return lambda;
}
Run Code Online (Sandbox Code Playgroud)

我对表达式不是很熟悉,我不知道如何将否定放入表达式函数中,并且在"Expression"类中找不到任何合适的方法.有没有类似的方法动态创建"不包含"表达式?

c# linq

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

使用jquery模板插件构建表

我感到无助.我想用jquery模板插件构建一个表,然后用响应中的数据填充表,如下所示:

[
     [
        {Row:0,Col:0},
        {Row:0,Col:1},
        {Row:0,Col:2},
        {Row:0,Col:3},
        {Row:0,Col:4},
        {Row:0,Col:5},
        {Row:0,Col:6}
     ],
     [
        {Row:1,Col:0},
        {Row:1,Col:1},
        {Row:1,Col:2},
        {Row:1,Col:3},
        {Row:1,Col:4},
        {Row:1,Col:5},
        {Row:1,Col:6}
     ]
]
Run Code Online (Sandbox Code Playgroud)

因此该表应该在每行中包含2行和7列.

这是我坚持的代码:

$('#trTemplate').tmpl(result.d).appendTo('#containerTable');

<script id="trTemplate" type="text/x-jquery-tmpl">
    {{each $data}}
        {{if $index < 2}}
            <tr>
                {{tmpl($value) "#tdTemplate"}}
            </tr>
        {{/if}}
    {{/each}}
</script>

<script id="tdTemplate" type="text/x-jquery-tmpl">
    {{each $data}}
        <td>${Col}</td>
    {{/each}}
</script>

<table id="containerTable">
</table>
Run Code Online (Sandbox Code Playgroud)

我尝试了不同的方法,改变了数据源的外观,工作正常,尝试构建没有模板的表,但我真的需要知道如何构建一个具有此类数据源和使用模板的表?谢谢您的帮助.

jquery jquery-templates

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

Ghostscript PDF 到 PNG:输出始终为 595x842 (A4)

我尝试将 PDF 转换为 PNG,但输出图像始终为 A4,但是源 PDF 非常大。这是我的命令:

-dNOPAUSE ^
-dBATCH ^
-dSAFER ^
-sDEVICE=png16m ^
-dFirstPage=1 ^
-sOutputFile="D:\PDF.png" ^
 "D:\PDF.pdf" ^
-sPAPERSIZE=a1
Run Code Online (Sandbox Code Playgroud)

我尝试了几个选项(-r、-g、-sDEFAULTPAPERSIZE),但都没有奏效。

如何强制输出图像尺寸?

PS:我的PDF文件

ghostscript

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

tinymce setContent删除新行

如果我在textarea中预装了内容,那么我将新行转换为"br"标签.

但是如果我尝试使用setContent函数动态设置内容(不粘贴)到tinymce textarea,则缺少新行.

我使用v.3.4.7,尝试了v.3.5.6(到目前为止的最新版本)并且即使在页面加载时也会删除新行.

<script type="text/javascript">
    tinyMCE.init({
        mode: "textareas",
        editor_selector: "EmailBody",
        theme: "advanced",
        language: "en",
        charLimit: 10,
        plugins: "table,advhr,advlink,insertdatetime,preview,print,contextmenu,paste,directionality",
        theme_advanced_buttons1_add: "fontselect,fontsizeselect",
        theme_advanced_buttons2_add: "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
        theme_advanced_buttons2_add_before: "pastetext,pasteword,separator",
        theme_advanced_buttons3_add_before: "tablecontrols,separator",
        theme_advanced_buttons3_add: "advhr,separator,ltr,rtl,separator",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        plugi2n_insertdate_dateFormat: "%Y-%m-%d",
        plugi2n_insertdate_timeFormat: "%H:%M:%S",
        paste_use_dialog: false,
        theme_advanced_resizing: false,
        theme_advanced_resize_horizontal: true,
        paste_auto_cleanup_on_paste: true,
        paste_convert_headers_to_strong: false,
        paste_remove_spans: true,
        width: "100%",
        paste_remove_styles: true,
        valid_elements: "a[href|target=_blank],strong/b,div[align],p,br,i,u",
        content_css: "/css/tinymce_bigger_default_font.css",
        forced_root_block: false,
        force_br_newlines: true,
        force_p_newlines: false,
        apply_source_formatting: false,
        remove_linebreaks: false,
        convert_newlines_to_brs: true
    });
</script>

function Click()
{
    var text = document.getElementById("preText").innerText; …
Run Code Online (Sandbox Code Playgroud)

tinymce

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

使用C#在Excel工作表中查找粗体文本

如何在Excel工作表的单元格中查找粗体文本?我正在使用C#,OLEDB和ADO.NET来读取xls文件,但我没有解决如何解决我的任务.我需要使用Iterop.Excel吗?

.net c# excel

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

LSP:条件创建对象

我想知道我是否遵循正确的道路,因为我觉得以下代码是错误的.对不起,我不知道如何正确地命名这个问题.

我有一个ShapeEntity类,用于从DB加载数据.Shape还有其他具体的类(我将来可能会有很多类)所以我想用LSP来绘制这些形状,这就是我使用IShape抽象的原因.我通过使用ShapeEntity提供的DB信息来实例化具体的形状对象.

所以我关注的是Main()函数,我只使用简单的if-else创建了这些Shapes.这是使用if-else块创建"未知"对象的正确方法吗?也许我可以将Shape对象创建为某种ShapeService?怎么能以其他方式解决?

public class ShapeEntity
{
    int idShape { get; set; }
}

public interface IShape
{
    void Draw();
}

public class Square : IShape
{
    public void Draw() { }
}

public class Rectangle : IShape
{
    public void Draw() { }
}

public class Canvas()
{
    public static void Main()
    {
        List<IShape> Shapes = new List<IShape>();

        foreach(ShapeEntity ShapeItem in ShapeRepository.GetAll())
        {
            if(ShapeItem.idShape == 1)
            {
                Shapes.Add(new Square());
            }
            else if(ShapeItem.idShape == 2)
            {
                Shapes.Add(new Rectangle());
            }
        } …
Run Code Online (Sandbox Code Playgroud)

c# oop

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

标签 统计

c# ×3

.net ×1

excel ×1

ghostscript ×1

jquery ×1

jquery-templates ×1

linq ×1

oop ×1

tinymce ×1