小编Max*_*Max的帖子

Delphi中的相互引用记录(Win32)

是否有任何解决方法在Delphi中创建相互引用记录?这是代码的简化版本:

MyRec1 = record
  arr: MyRec2Array;
end;

MyRec2 = record
  mr: MyRec1;
end;

MyRec2Array = array of MyRec2;
Run Code Online (Sandbox Code Playgroud)

显然是转发记录类型的声明

MyRec2 = record;
Run Code Online (Sandbox Code Playgroud)

在Delphi for Win32中不起作用.

切换到类而不是记录是不好的,因为这会增加内存消耗和代码复杂性,所以我宁愿留在记录中.

有什么建议?

delphi data-structures

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

将对xml架构的引用添加到XML序列化输出

使用代码序列化对象时:

var xmlSerializer = new XmlSerializer(typeof(MyType));
using (var xmlWriter = new StreamWriter(outputFileName))
{
    xmlSerializer.Serialize(xmlWriter, myTypeInstance);
}
Run Code Online (Sandbox Code Playgroud)

在输出xml文件中,我得到:

<MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Run Code Online (Sandbox Code Playgroud)

如何向其添加对xml架构的引用,因此它看起来像这样:

<MyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xsi:noNamespaceSchemaLocation="mySchema.xsd">
Run Code Online (Sandbox Code Playgroud)

c# xml-serialization

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

F#交互式自动完成

在VS2010中有没有在F#interactive中获得自动完成的选项?

.net f# visual-studio-2010 visual-studio

9
推荐指数
2
解决办法
2496
查看次数

用于在运行时记录调用堆栈的库(Windows/Linux)

我需要一种方法来记录调试日志中的函数堆栈跟踪,以帮助我诊断缺陷.问题是我需要在Windows和Linux上使用C++实现它.

经过一番研究,我发现:

  • 对于Windows实现,我可以使用StackWalk64 API函数和系列.
  • 在Linux下,我发现libunwind听起来很棒.
  • 或者,我可以使用glibc的回溯

在开始工作之前,我想要一些建议,如果这是正确的方法,并询问是否有一个已经编写的多平台库可以提供帮助.我怀疑我不是第一个需要这个的程序员.:)

c++ linux windows debugging

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

限制对特定元素组的ID引用

假设我们有以下架构:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="a_elements">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="a_element" maxOccurs="unbounded">
                            <xs:complexType>
                                <xs:attribute name="id" type="xs:ID" use="required"/>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="b_elements">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="b_element" maxOccurs="unbounded">
                            <xs:complexType>
                                <xs:attribute name="id" type="xs:ID" use="required"/>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="c_elements">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="c_element" maxOccurs="unbounded">
                            <xs:complexType>
                                <xs:attribute name="id" type="xs:ID" use="required"/>
                                <xs:attribute name="ref" type="xs:IDREF" use="required"/>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

这是示例xml文件:

<root>
    <a_elements>
        <a_element id="id1"/>
        <a_element id="id2"/>
    </a_elements>
    <b_elements>
        <b_element id="id3"/>
        <b_element id="id4"/>
    </b_elements> …
Run Code Online (Sandbox Code Playgroud)

xml xsd

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

如何避免手动实现INotifyPropertyChanged

有没有办法避免这种情况.我有很多绑定到DataGridViews的类,它们只是带有默认getter和setter的简单属性集合.所以这些类非常简单.现在我需要为它们实现INotifyPropertyChanged接口,这将增加很多代码量.是否有任何类可以继承以避免编写所有这些无聊的代码?我认为我可以从某个类继承我的类,并用一些属性装饰属性,它会发挥魔力.那可能吗?

我很清楚面向方面编程,但我更倾向于以面向对象的方式.

c# data-binding collections winforms

8
推荐指数
2
解决办法
1397
查看次数

具有CheckBox单元格问题的DataGridView

我有一个带有DataGridViewCheckBoxColumn列的DataGridView,它被数据绑定到一个列表.问题是此复选框的数据绑定布尔属性不是在选中/取消选中复选框时更新,而是在CellLeave事件之后,换句话说在单元格失去焦点之后更新.我希望在检查/取消选中后立即更新此属性.有一个事件CurrentCellDirtyStateChanged在检查/取消选中后立即触发,因此我可以使用它来手动更新该属性.有一个更好的方法吗?

c# data-binding winforms

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

使用不可变字典

我正在尝试以功能方式创建字典.我玩了一下,并能够用这段代码连接两个词典:

let d1 = dict [(1, "one"); (2, "two")]
let d2 = dict [(4, "four")]
let d = List.ofSeq d1 @ List.ofSeq d2
Run Code Online (Sandbox Code Playgroud)

这是在F#中使用不可变字典的正确方法吗?看起来有点复杂.

f# dictionary

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

记录类型推断

在以下代码段中

type myrec1 = {x: int; y: int}
type myrec2 = {x: int; y: int; z: int}

let p1 = {x = 1; y = 1}  // Error. p1 compiler assumes p1 has the type myrec2

// It works with additional type specification
let p1: myrec1 = {x = 1; y = 1}
let p2: myrec2 = {x = 1; y = 1; z = 1}
Run Code Online (Sandbox Code Playgroud)

带注释的行无法编译.由于某种原因,类型检查器无法确定p1的类型应该是myrec1.是因为这种类型推断的情况根本无法解决,还是只是F#类型推断的限制?

f# type-inference

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

在Visual C++ 2015中使用64位编译器

我有一个包含很多模板的C++项目,但无法编译fatal error C1060: compiler is out of heap space.有足够的免费RAM.我尝试用/ Zm编译器选项支付,但它没有帮助.我可以看到Visual Studio使用32位版本的编译器,我认为这是导致此错误的原因.有没有办法强制Visual Studio使用64位编译器?

UPDATE

我的问题不是重复的.我看到了其他问题,并尝试了这些建议.但在我的情况下,编译器需要超过6 GB的RAM来编译项目.这是64位编译器分配的最大RAM量.我可以在构建项目时使用64位编译器msbuild,但是我想从Visual Studio构建它,默认情况下使用32位编译器.我想强制它使用64位编译器.通过64位编译器,我的意思是编译器不仅创建64位应用程序,而且是64位应用程序本身.

c++ visual-studio-2015

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