You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -0,0 +1,65 @@
|
||||
// <copyright>
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace System.ServiceModel.Channels
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.Runtime;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ServiceModel.Configuration;
|
||||
using System.Xml;
|
||||
|
||||
internal static class EncoderHelpers
|
||||
{
|
||||
internal static XmlDictionaryReaderQuotas GetBufferedReadQuotas(XmlDictionaryReaderQuotas encoderQuotas)
|
||||
{
|
||||
XmlDictionaryReaderQuotas bufferedReadQuotas = new XmlDictionaryReaderQuotas();
|
||||
encoderQuotas.CopyTo(bufferedReadQuotas);
|
||||
|
||||
// now we have the quotas from the encoder, we need to update the values with the new quotas from the default read quotas.
|
||||
if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxStringContentLength))
|
||||
{
|
||||
bufferedReadQuotas.MaxStringContentLength = EncoderDefaults.BufferedReadDefaultMaxStringContentLength;
|
||||
}
|
||||
|
||||
if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxArrayLength))
|
||||
{
|
||||
bufferedReadQuotas.MaxArrayLength = EncoderDefaults.BufferedReadDefaultMaxArrayLength;
|
||||
}
|
||||
|
||||
if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxBytesPerRead))
|
||||
{
|
||||
bufferedReadQuotas.MaxBytesPerRead = EncoderDefaults.BufferedReadDefaultMaxBytesPerRead;
|
||||
}
|
||||
|
||||
if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxNameTableCharCount))
|
||||
{
|
||||
bufferedReadQuotas.MaxNameTableCharCount = EncoderDefaults.BufferedReadDefaultMaxNameTableCharCount;
|
||||
}
|
||||
|
||||
if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxDepth))
|
||||
{
|
||||
bufferedReadQuotas.MaxDepth = EncoderDefaults.BufferedReadDefaultMaxDepth;
|
||||
}
|
||||
|
||||
return bufferedReadQuotas;
|
||||
}
|
||||
|
||||
private static bool IsDefaultQuota(XmlDictionaryReaderQuotas quotas, XmlDictionaryReaderQuotaTypes quotaType)
|
||||
{
|
||||
switch (quotaType)
|
||||
{
|
||||
case XmlDictionaryReaderQuotaTypes.MaxDepth:
|
||||
case XmlDictionaryReaderQuotaTypes.MaxStringContentLength:
|
||||
case XmlDictionaryReaderQuotaTypes.MaxArrayLength:
|
||||
case XmlDictionaryReaderQuotaTypes.MaxBytesPerRead:
|
||||
case XmlDictionaryReaderQuotaTypes.MaxNameTableCharCount:
|
||||
return (quotas.ModifiedQuotas & quotaType) == 0x00;
|
||||
}
|
||||
|
||||
Fx.Assert("invalid quota type.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user