走过海棠暮

文章 评论 浏览 25

走过海棠暮 2024-08-22 10:14:59

尝试 inv.GetType().GetProperty("BillTo+Address");

Try inv.GetType().GetProperty("BillTo+Address");

在 C# 中使用反射获取嵌套对象的属性

走过海棠暮 2024-08-22 10:00:39

在这种情况下...很多程序员倾向于只谈论最糟糕的例子...因为 UI 确实取决于个人品味。

看看这个问题最糟糕的例子:
Stackoverflow 问题

从我的角度来看,我更喜欢清晰的外观...没有什么花哨的东西等。 ..但这实际上取决于软件和主题...希望这有帮助

In this case... a lot of programmers tend to talk only about the worst examples...cause UI really depends on personel taste.

Have a look at this question for the worst examples:
Stackoverflow Question

From my point of view i prefer clear looks...nothing fancy etc...but it really depends on the software and topic...hope this helps

软件 UI 的灵感

走过海棠暮 2024-08-22 09:12:28

网络协议基本上就像一种口语。它是通过通过网络/互联网发送和接收专门准备的消息的代码来实现的,就像您说话所需的声带(网络和硬件)和真正理解某人所说内容的大脑(协议栈/软件)一样。

有时,协议直接在硬件上实现[出于速度原因](例如 LAN 的以太网协议) - 但始终需要软件/代码来使用协议执行一些有用的操作。

您可能对此感兴趣:

A network protocol is basically like a spoken language. It is implemented by code that sends and receives specially prepared messages over the network/internet, much like the vocal chords you need to speak (the network and hardware) and a brain to actually understand what someone said (the protocol stack/software).

Sometimes protocols are implemented directly on the hardware [for speed reasons] (like the Ethernet protocol for LANs) - but it is always software/code required to do something useful with a protocol.

This might be interesting for you:

网络协议是如何实现的?

走过海棠暮 2024-08-22 06:51:27

如果此组合框具有 CBS_OWNERDRAWFIXEDCBS_OWNERDRAWVARIABLE 样式,或者包含的列表框具有 LBS_OWNERDRAWFIXEDLBS_OWNERDRAWVARIABLE 样式。那么控件根本不知道该文本。当应用程序使用其中一种样式时,每当控件需要绘制时,它都会收到 WM_DRAWITEM 消息,然后它会从其口袋中提取文本并在需要的地方绘制它。

这是一个技巧,允许应用程序快速轻松地更改列表框或组合框的内容,它主要在内容不稳定或有大量项目时使用。这是绕过列表框/组合框可以容纳的项目数量限制的一种方法。

使用 Spy++ 检查这些窗口上的样式。

If this combobox has the CBS_OWNERDRAWFIXED or CBS_OWNERDRAWVARIABLE style, or the contained listbox has the LBS_OWNERDRAWFIXED or LBS_OWNERDRAWVARIABLE style. then the text isn't known by the control at all. When an app uses one of these styles, it gets WM_DRAWITEM messages whenever the control needs to draw, then it pulls the text from it's pocket and draws it wherever it was asked to.

This is a trick that allows an application to quickly and easily change the contents of a listbox or combobox on the fly, it's mostly used when the contents are volatile or when there are LOTS of items. It's one way to get around the limit on the number of items an listbox/combobox can hold.

Use Spy++ to check the styles on these windows.

使用 UI 自动化获取组合框中的项目时出现奇怪的结果

走过海棠暮 2024-08-22 05:46:27

我知道这已经被标记为已回答,但如果在页面中找不到 ScriptManager,这是插入 ScriptManager 的代码:


public abstract class WebPartBase : WebPart
{
    protected override void OnInit(EventArgs e)
    {
        if (ScriptManager.GetCurrent(Page) == null)
        {
            ScriptManager scriptManager = new ScriptManager();
            scriptManager.ID = "ScriptManager1";
            scriptManager.EnablePartialRendering = true;
            Page.Form.Controls.AddAt(0, scriptManager);
        }
        base.OnInit(e);
    }
}

所有 Web 部件都继承自该基类。为了清楚起见,删除了所有其他代码,这仅用于脚本管理器,但您可以处理其中的 Web 部件错误和其他故障。

I know this is already marked as answered, but this is the code that inserts the ScriptManager if one is not found in the page:


public abstract class WebPartBase : WebPart
{
    protected override void OnInit(EventArgs e)
    {
        if (ScriptManager.GetCurrent(Page) == null)
        {
            ScriptManager scriptManager = new ScriptManager();
            scriptManager.ID = "ScriptManager1";
            scriptManager.EnablePartialRendering = true;
            Page.Form.Controls.AddAt(0, scriptManager);
        }
        base.OnInit(e);
    }
}

all webparts inherit from this base class. All the other code was removed for clarity, this only does the script manager but you can handle web part errors and other glitches in there.

SharePoint AJAX 实现:ScriptHandler 被添加两次

走过海棠暮 2024-08-22 04:27:32

如果您只想匹配第一个冒号,可以将 (.*)\:(.*) 更改为 ([^:]*)\:(.*)

或者,您可以使其成为非贪婪匹配,但我更喜欢说“不是冒号”。

If you only want to match up to first colon you could change (.*)\:(.*) to ([^:]*)\:(.*).

Alternatively, you could make it a non-greedy match, but I prefer saying "not colon".

如何让正则表达式忽略 URL 字符串?

走过海棠暮 2024-08-22 04:17:37

虽然你可能可以做到,但我不推荐它。只是因为其他人阅读代码并不清楚。

更好的方法就是在服务器端将它们组合起来。假设:

<select id="select-1" name="data_1[]"/>
...

<select id="select-2" name="data_2[]"/>
...

在 PHP 端:

$data1 = $_POST['data_1'];
$data2 = $_POST['data_2'];
$combined = array_merge($data1, $data2);

While you probably can do it I wouldn't recommend it. Just because it isn't that clear from someone else reading the code.

A better approach is simply to combine them serverside. Assuming:

<select id="select-1" name="data_1[]"/>
...

<select id="select-2" name="data_2[]"/>
...

On the PHP side:

$data1 = $_POST['data_1'];
$data2 = $_POST['data_2'];
$combined = array_merge($data1, $data2);

将选择框分组到数组中进行发布?

走过海棠暮 2024-08-22 04:02:32

根据MySQL的文档如何重置Root密码

UPDATE mysql.user SET password=PASSWORD("my-new-password") WHERE User='root';
FLUSH PRIVILEGES;

According to MySQL's documentation on How to Reset the Root Password:

UPDATE mysql.user SET password=PASSWORD("my-new-password") WHERE User='root';
FLUSH PRIVILEGES;

无法更改MySQL密码

走过海棠暮 2024-08-22 03:07:27

是否有“比较时将 ^M 视为换行符”之类的选项?

Git 2.16(2018 年第一季度)将会有一个,因为“diff”命令系列学会了忽略行尾回车符的差异。

请参阅 commit e9282f0(2017 年 10 月 26 日),作者:Junio C Hamano (gitster)
帮助者:Johannes Schindelin (dscho)
(由 Junio C Hamano -- gitster -- 合并于 提交 10f65c2,2017 年 11 月 27 日)

差异:--ignore-cr-at-eol

新选项--ignore-cr-at-eol告诉diff机制将(完整)行末尾的回车符视为它不存在。

就像其他“--ignore-*”选项一样忽略各种空白差异,这将有助于检查您所做的实际更改,而不会被虚假的 CRLF<-> 分散注意力;LF 由您的编辑器程序进行转换。

Is there an option like "treat ^M as newline when diffing" ?

There will be one with Git 2.16 (Q1 2018), as the "diff" family of commands learned to ignore differences in carriage return at the end of line.

See commit e9282f0 (26 Oct 2017) by Junio C Hamano (gitster).
Helped-by: Johannes Schindelin (dscho).
(Merged by Junio C Hamano -- gitster -- in commit 10f65c2, 27 Nov 2017)

diff: --ignore-cr-at-eol

A new option --ignore-cr-at-eol tells the diff machinery to treat a carriage-return at the end of a (complete) line as if it does not exist.

Just like other "--ignore-*" options to ignore various kinds of whitespace differences, this will help reviewing the real changes you made without getting distracted by spurious CRLF<->LF conversion made by your editor program.

制作“git diff”忽略^M

走过海棠暮 2024-08-21 22:47:23

由于我不是 IIS 的忠实粉丝,所以我仍然会使用 Apache + mod_wsgi。 mod_wsgi 是官方推荐的部署 django 应用程序的方式,根据 http://docs .djangoproject.com/en/dev/howto/deployment/modwsgi/

As I'm not a big fan of IIS, I'd still use Apache + mod_wsgi. mod_wsgi is officially recommended way of deploying django apps, according to http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/

Windows 上的最小生产 Django 服务器

走过海棠暮 2024-08-21 21:16:18

我可能会建议 declxml

全面披露:我编写这个库是因为我正在寻找一种在 XML 和 Python 数据结构之间进行转换的方法,而无需使用 ElementTree 编写数十行命令式解析/序列化代码。

通过 declxml,您可以使用处理器以声明方式定义 XML 文档的结构以及如何在 XML 和 Python 数据结构之间进行映射。处理器用于序列化和解析以及基本级别​​的验证。

解析为 Python 数据结构非常简单:

import declxml as xml

xml_string = """
<foo>
   <bar>
      <type foobar="1"/>
      <type foobar="2"/>
   </bar>
</foo>
"""

processor = xml.dictionary('foo', [
    xml.dictionary('bar', [
        xml.array(xml.integer('type', attribute='foobar'))
    ])
])

xml.parse_from_string(processor, xml_string)

生成输出:

{'bar': {'foobar': [1, 2]}}

您还可以使用相同的处理器将数据序列化为 XML

data = {'bar': {
    'foobar': [7, 3, 21, 16, 11]
}}

xml.serialize_to_string(processor, data, indent='    ')

生成以下输出

<?xml version="1.0" ?>
<foo>
    <bar>
        <type foobar="7"/>
        <type foobar="3"/>
        <type foobar="21"/>
        <type foobar="16"/>
        <type foobar="11"/>
    </bar>
</foo>

如果您想使用对象而不是字典,您可以定义处理器将数据转换为 和也来自物体。

import declxml as xml

class Bar:

    def __init__(self):
        self.foobars = []

    def __repr__(self):
        return 'Bar(foobars={})'.format(self.foobars)


xml_string = """
<foo>
   <bar>
      <type foobar="1"/>
      <type foobar="2"/>
   </bar>
</foo>
"""

processor = xml.dictionary('foo', [
    xml.user_object('bar', Bar, [
        xml.array(xml.integer('type', attribute='foobar'), alias='foobars')
    ])
])

xml.parse_from_string(processor, xml_string)

产生以下输出

{'bar': Bar(foobars=[1, 2])}

I might suggest declxml.

Full disclosure: I wrote this library because I was looking for a way to convert between XML and Python data structures without needing to write dozens of lines of imperative parsing/serialization code with ElementTree.

With declxml, you use processors to declaratively define the structure of your XML document and how to map between XML and Python data structures. Processors are used to for both serialization and parsing as well as for a basic level of validation.

Parsing into Python data structures is straightforward:

import declxml as xml

xml_string = """
<foo>
   <bar>
      <type foobar="1"/>
      <type foobar="2"/>
   </bar>
</foo>
"""

processor = xml.dictionary('foo', [
    xml.dictionary('bar', [
        xml.array(xml.integer('type', attribute='foobar'))
    ])
])

xml.parse_from_string(processor, xml_string)

Which produces the output:

{'bar': {'foobar': [1, 2]}}

You can also use the same processor to serialize data to XML

data = {'bar': {
    'foobar': [7, 3, 21, 16, 11]
}}

xml.serialize_to_string(processor, data, indent='    ')

Which produces the following output

<?xml version="1.0" ?>
<foo>
    <bar>
        <type foobar="7"/>
        <type foobar="3"/>
        <type foobar="21"/>
        <type foobar="16"/>
        <type foobar="11"/>
    </bar>
</foo>

If you want to work with objects instead of dictionaries, you can define processors to transform data to and from objects as well.

import declxml as xml

class Bar:

    def __init__(self):
        self.foobars = []

    def __repr__(self):
        return 'Bar(foobars={})'.format(self.foobars)


xml_string = """
<foo>
   <bar>
      <type foobar="1"/>
      <type foobar="2"/>
   </bar>
</foo>
"""

processor = xml.dictionary('foo', [
    xml.user_object('bar', Bar, [
        xml.array(xml.integer('type', attribute='foobar'), alias='foobars')
    ])
])

xml.parse_from_string(processor, xml_string)

Which produces the following output

{'bar': Bar(foobars=[1, 2])}

如何解析 XML 并获取特定节点属性的实例?

走过海棠暮 2024-08-21 17:01:13

由于 Roslyn 是开源的,代码分析工具触手可及,而且它们是为性能而编写的。 (目前它们处于预发布状态)。

但是,我无法谈论加载程序集的性能成本。

使用 nuget 安装工具:

Install-Package Microsoft.CodeAnalysis -Pre

提出您的问题:

var isValid = Microsoft.CodeAnalysis.CSharp.SyntaxFacts.IsValidIdentifier("I'mNotValid");
Console.WriteLine(isValid);     // False

With Roslyn being open source, code analysis tools are right at your fingertips, and they're written for performance. (Right now they're in pre-release).

However, I can't speak to the performance cost of loading the assembly.

Install the tools using nuget:

Install-Package Microsoft.CodeAnalysis -Pre

Ask your question:

var isValid = Microsoft.CodeAnalysis.CSharp.SyntaxFacts.IsValidIdentifier("I'mNotValid");
Console.WriteLine(isValid);     // False

C# 中有没有方法来检查字符串是否是有效标识符

走过海棠暮 2024-08-21 14:52:41

您应该能够通过使用 ComboBoxItem 上的“IsEnabled”属性来完成此操作。在我的快速测试中,

<ComboBox>
    <ComboBoxItem>Item1</ComboBoxItem>
    <ComboBoxItem IsEnabled="False">Item2</ComboBoxItem>
    <ComboBoxItem>Item3</ComboBoxItem>
</ComboBox>

结果是:生成一个包含 3 个项目的组合框,并且单击时不会选择“Item2”。

You should be able to accomplish this by using the 'IsEnabled' property on the ComboBoxItem. In my quick test, this:

<ComboBox>
    <ComboBoxItem>Item1</ComboBoxItem>
    <ComboBoxItem IsEnabled="False">Item2</ComboBoxItem>
    <ComboBoxItem>Item3</ComboBoxItem>
</ComboBox>

Results in a ComboBox with 3 items, and "Item2" does not get selected when clicked.

WPF 禁止单击 ComboBoxItem

走过海棠暮 2024-08-21 07:50:55

还值得注意的是 F# 的出现限制了微软对 Scala 的兴趣,因为他们现在拥有了自己的“受祝福的”函数式语言。 NIH。

It's also probably worth noting that the advent of F# has limited Microsoft's interest in Scala, in that they now have a "blessed" functional language of their own. NIH.

CLR 上的 Scala

走过海棠暮 2024-08-21 07:22:50

本身没有正确的方法,两者都应该有效。

在第一个示例中,您需要确保 <<< 之间没有空格。和 EOM,后面没有分号。

示例:

$myvar = <<<END
<div>My html here</div>
END;
echo $myvar;

另一种选择是使用:

echo "<div>My html here</div>";

There's no correct way perse, both should work.

In your first example you need to make sure there is no space between <<< and EOM and no semicolon afterwards.

Example:

$myvar = <<<END
<div>My html here</div>
END;
echo $myvar;

another option would be to use:

echo "<div>My html here</div>";

PHP HTML 输出

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文