简体   繁体   English

readerQuotas-> maxStringContentLength到底指什么?

[英]What does readerQuotas --> maxStringContentLength exactly refer to?

I have read on msdn that the attribute maxStringContentLength of the readerQuotas for a WCF client means: 我在msdn上阅读过,WCF客户端的readerQuotas的属性maxStringContentLength表示:

A positive integer that specifies the maximum characters allowed in XML element content. 一个正整数,指定XML元素内容中允许的最大字符。 The default is 8192. 默认值为8192。

I am probably a bit thick here, but what exactly are they refering to when saying XML element content? 我在这里可能有点厚,但是当说XML元素内容时,它们到底指的是什么? Is that the content in one XML element? 那是一个XML元素中的内容吗? And would it include any nested child elements? 并且它会包含任何嵌套的子元素吗? Or is that the limit of each element only without nested elements? 还是每个元素的限制仅不包含嵌套元素?

Eg in the following structure: 例如,以下结构:

<a>
 <b>baap</b>
 <c>beep</c>
</a>

Would tag a cause an overflow of the maxStringContentLength if baap and beep together were over the limit? 如果baap和beep在一起超过限制,是否会标记maxStringContentLength的溢出原因? Or would only b or c cause one if their respective contents were over the limit? 或如果b或c各自的含量超出限制,只会引起b或c的原因? Or am I totally missing something? 还是我完全想念什么?

Thanks all! 谢谢大家!

From the MSDN : 从MSDN

MaxStringContentLength This quota limits the maximum string size that the XML reader returns. MaxStringContentLength此配额限制XML阅读器返回的最大字符串大小。 This quota does not limit memory consumption in the XML reader itself, but in the component that is using the reader. 此配额不限制XML读取器本身的内存消耗,而是在使用该读取器的组件中的内存消耗。 For example, when the DataContractSerializer uses a reader secured with MaxStringContentLength, it does not deserialize strings larger than this quota. 例如,当DataContractSerializer使用受MaxStringContentLength保护的读取器时,它不会反序列化大于此配额的字符串。 When using the XmlDictionaryReader class directly, not all methods respect this quota, but only the methods that are specifically designed to read strings, such as the ReadContentAsString method. 直接使用XmlDictionaryReader类时,并非所有方法都遵循此配额,而是仅专门设计用于读取字符串的方法(例如ReadContentAsString方法)。 The Value property on the reader is not affected by this quota, and thus should not be used when the protection this quota provides is necessary. 读取器上的Value属性不受此配额的影响,因此在需要此配额提供的保护时,不应使用该属性。

It limits the maximum size of a string that is returned, either an XML string or a method that returns a string. 它限制了返回的字符串的最大大小,该字符串可以是XML字符串,也可以是返回字符串的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM