Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Net / System / Net / Configuration / HttpWebRequestElement.cs / 1 / HttpWebRequestElement.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Configuration
{
using System;
using System.Configuration;
using System.Reflection;
using System.Security.Permissions;
public sealed class HttpWebRequestElement : ConfigurationElement
{
public HttpWebRequestElement()
{
this.properties.Add(this.maximumResponseHeadersLength);
this.properties.Add(this.maximumErrorResponseLength);
this.properties.Add(this.maximumUnauthorizedUploadLength);
this.properties.Add(this.useUnsafeHeaderParsing);
}
protected override void PostDeserialize()
{
// Perf optimization. If the configuration is coming from machine.config
// It is safe and we don't need to check for permissions.
if (EvaluationContext.IsMachineLevel)
return;
PropertyInformation[] protectedProperties = {
ElementInformation.Properties[ConfigurationStrings.MaximumResponseHeadersLength],
ElementInformation.Properties[ConfigurationStrings.MaximumErrorResponseLength]
};
foreach (PropertyInformation property in protectedProperties)
if (property.ValueOrigin == PropertyValueOrigin.SetHere)
{
try {
ExceptionHelper.WebPermissionUnrestricted.Demand();
} catch (Exception exception) {
throw new ConfigurationErrorsException(
SR.GetString(SR.net_config_property_permission,
property.Name),
exception);
}
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
return this.properties;
}
}
[ConfigurationProperty(ConfigurationStrings.maximumUnauthorizedUploadLength, DefaultValue=(int)(-1))]
public int MaximumUnauthorizedUploadLength
{
get { return (int)this[this.maximumUnauthorizedUploadLength]; }
set { this[this.maximumUnauthorizedUploadLength] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaximumErrorResponseLength, DefaultValue=(int)(64))]
public int MaximumErrorResponseLength
{
get { return (int)this[this.maximumErrorResponseLength]; }
set { this[this.maximumErrorResponseLength] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaximumResponseHeadersLength, DefaultValue= 64)]
public int MaximumResponseHeadersLength
{
get { return (int)this[this.maximumResponseHeadersLength]; }
set { this[this.maximumResponseHeadersLength] = value; }
}
[ConfigurationProperty(ConfigurationStrings.UseUnsafeHeaderParsing, DefaultValue= false)]
public bool UseUnsafeHeaderParsing
{
get { return (bool) this[this.useUnsafeHeaderParsing]; }
set { this[this.useUnsafeHeaderParsing] = value; }
}
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
readonly ConfigurationProperty maximumResponseHeadersLength =
new ConfigurationProperty(ConfigurationStrings.MaximumResponseHeadersLength,
typeof(int),
64,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty maximumErrorResponseLength =
new ConfigurationProperty(ConfigurationStrings.MaximumErrorResponseLength,
typeof(int),
64,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty maximumUnauthorizedUploadLength =
new ConfigurationProperty(ConfigurationStrings.maximumUnauthorizedUploadLength,
typeof(int),
-1,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty useUnsafeHeaderParsing =
new ConfigurationProperty(ConfigurationStrings.UseUnsafeHeaderParsing,
typeof(bool),
false,
ConfigurationPropertyOptions.None);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Configuration
{
using System;
using System.Configuration;
using System.Reflection;
using System.Security.Permissions;
public sealed class HttpWebRequestElement : ConfigurationElement
{
public HttpWebRequestElement()
{
this.properties.Add(this.maximumResponseHeadersLength);
this.properties.Add(this.maximumErrorResponseLength);
this.properties.Add(this.maximumUnauthorizedUploadLength);
this.properties.Add(this.useUnsafeHeaderParsing);
}
protected override void PostDeserialize()
{
// Perf optimization. If the configuration is coming from machine.config
// It is safe and we don't need to check for permissions.
if (EvaluationContext.IsMachineLevel)
return;
PropertyInformation[] protectedProperties = {
ElementInformation.Properties[ConfigurationStrings.MaximumResponseHeadersLength],
ElementInformation.Properties[ConfigurationStrings.MaximumErrorResponseLength]
};
foreach (PropertyInformation property in protectedProperties)
if (property.ValueOrigin == PropertyValueOrigin.SetHere)
{
try {
ExceptionHelper.WebPermissionUnrestricted.Demand();
} catch (Exception exception) {
throw new ConfigurationErrorsException(
SR.GetString(SR.net_config_property_permission,
property.Name),
exception);
}
}
}
protected override ConfigurationPropertyCollection Properties
{
get
{
return this.properties;
}
}
[ConfigurationProperty(ConfigurationStrings.maximumUnauthorizedUploadLength, DefaultValue=(int)(-1))]
public int MaximumUnauthorizedUploadLength
{
get { return (int)this[this.maximumUnauthorizedUploadLength]; }
set { this[this.maximumUnauthorizedUploadLength] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaximumErrorResponseLength, DefaultValue=(int)(64))]
public int MaximumErrorResponseLength
{
get { return (int)this[this.maximumErrorResponseLength]; }
set { this[this.maximumErrorResponseLength] = value; }
}
[ConfigurationProperty(ConfigurationStrings.MaximumResponseHeadersLength, DefaultValue= 64)]
public int MaximumResponseHeadersLength
{
get { return (int)this[this.maximumResponseHeadersLength]; }
set { this[this.maximumResponseHeadersLength] = value; }
}
[ConfigurationProperty(ConfigurationStrings.UseUnsafeHeaderParsing, DefaultValue= false)]
public bool UseUnsafeHeaderParsing
{
get { return (bool) this[this.useUnsafeHeaderParsing]; }
set { this[this.useUnsafeHeaderParsing] = value; }
}
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
readonly ConfigurationProperty maximumResponseHeadersLength =
new ConfigurationProperty(ConfigurationStrings.MaximumResponseHeadersLength,
typeof(int),
64,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty maximumErrorResponseLength =
new ConfigurationProperty(ConfigurationStrings.MaximumErrorResponseLength,
typeof(int),
64,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty maximumUnauthorizedUploadLength =
new ConfigurationProperty(ConfigurationStrings.maximumUnauthorizedUploadLength,
typeof(int),
-1,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty useUnsafeHeaderParsing =
new ConfigurationProperty(ConfigurationStrings.UseUnsafeHeaderParsing,
typeof(bool),
false,
ConfigurationPropertyOptions.None);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- JavascriptCallbackMessageInspector.cs
- WebPartDescription.cs
- CacheMode.cs
- TreeIterator.cs
- PropertyReferenceSerializer.cs
- HtmlContainerControl.cs
- CompilerError.cs
- HtmlControlPersistable.cs
- ChannelSinkStacks.cs
- Util.cs
- IMembershipProvider.cs
- XmlDataImplementation.cs
- GridViewCommandEventArgs.cs
- OracleBFile.cs
- PathSegmentCollection.cs
- RuleSettings.cs
- HwndSource.cs
- ProfileService.cs
- DBNull.cs
- LinqDataSource.cs
- ConnectionStringSettings.cs
- WebBrowserSiteBase.cs
- TextDecorationCollection.cs
- DbFunctionCommandTree.cs
- CatalogPartDesigner.cs
- PathData.cs
- SequenceRangeCollection.cs
- IntSecurity.cs
- EntityDataSourceView.cs
- BitArray.cs
- ContravarianceAdapter.cs
- PropertyGridDesigner.cs
- ResXResourceSet.cs
- ConsoleTraceListener.cs
- NamespaceQuery.cs
- FrameworkElementAutomationPeer.cs
- Vector.cs
- TypeConverters.cs
- TlsnegoTokenAuthenticator.cs
- RequestCacheEntry.cs
- LinkArea.cs
- Timer.cs
- Vector3DConverter.cs
- PixelShader.cs
- CalendarTable.cs
- XmlSchemaSimpleTypeUnion.cs
- RichTextBox.cs
- CountdownEvent.cs
- securitymgrsite.cs
- ArithmeticException.cs
- Int32AnimationUsingKeyFrames.cs
- AsyncCompletedEventArgs.cs
- relpropertyhelper.cs
- StrokeNodeOperations.cs
- FieldAccessException.cs
- OrderedDictionary.cs
- WebPartConnectionsEventArgs.cs
- UInt32Storage.cs
- HostExecutionContextManager.cs
- DataObjectEventArgs.cs
- TextUtf8RawTextWriter.cs
- DefaultClaimSet.cs
- XmlSchemaGroupRef.cs
- AdditionalEntityFunctions.cs
- ToolStripOverflowButton.cs
- TemplateControlBuildProvider.cs
- HttpException.cs
- KeyedHashAlgorithm.cs
- FieldMetadata.cs
- ImageSourceConverter.cs
- UndoManager.cs
- ParameterToken.cs
- Brush.cs
- ListViewGroup.cs
- SmtpReplyReaderFactory.cs
- UiaCoreApi.cs
- PrintEvent.cs
- FloatMinMaxAggregationOperator.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- EntityDataSourceContextDisposingEventArgs.cs
- QueryCacheManager.cs
- CodeNamespaceCollection.cs
- StringConverter.cs
- XmlChildNodes.cs
- PriorityBindingExpression.cs
- ListItemParagraph.cs
- EventProviderWriter.cs
- DbConnectionStringBuilder.cs
- ImageMap.cs
- FixedPosition.cs
- SecurityMode.cs
- SweepDirectionValidation.cs
- TemplateContentLoader.cs
- CompatibleComparer.cs
- DataGridHeaderBorder.cs
- DataGridViewCellEventArgs.cs
- ImageIndexEditor.cs
- HttpProfileGroupBase.cs
- StylusPoint.cs
- ExecutionEngineException.cs