本文介绍了以编程方式构建RunProperties的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! Hi group,我从OpenXML SDK的第2版开始,我有一个关于以编程方式构建RunProperties对象的问题。假设我使用以下代码为运行属性对象添加粗体和下划线: RunProperties rPr = new RunProperties(); rPr.Append(new Bold()); Debug.Assert (rPr.Bold!= null); rPr.Append(new Underline()); Debug.Assert(rPr.Underline!= null); 这里的断言没有失败, rPr对象变为粗体和下划线。相反,如果我反转添加子项的顺序,例如: rPr = new RunProperties (); rPr.Append(new Underline()); Debug.Assert(rPr.Underline!= null); rPr.Append(new Bold()); Debug.Assert (rPr.Bold!= null); 第二个断言FAILS,即使孩子数是2而不是1.那么应该如何做呢?是否有以编程方式构建此类对象的预期方法? Thanx! 解决方案 Hi group,I'm beginning with version 2 of the OpenXML SDK and I've a question about building a RunProperties object programmatically. Say I use the following code to add bold and underline to a run properties object:RunProperties rPr = new RunProperties();rPr.Append(new Bold());Debug.Assert(rPr.Bold != null);rPr.Append(new Underline());Debug.Assert(rPr.Underline != null);Here the assertions do not fail and the rPr object gets both bold and underline. If instead I invert the order in which children are added, like:rPr = new RunProperties();rPr.Append(new Underline());Debug.Assert(rPr.Underline != null);rPr.Append(new Bold());Debug.Assert(rPr.Bold != null);The 2nd assertion FAILS even if the children count is 2 instead of 1. So how should this be done? Is there an intended way of building such objects programmatically?Thanx! 解决方案 这篇关于以编程方式构建RunProperties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-14 13:53