Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / ScopedMessagePartSpecification.cs / 1 / ScopedMessagePartSpecification.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Security
{
using System.Collections.Generic;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.ServiceModel.Security;
using System.Xml;
public class ScopedMessagePartSpecification
{
MessagePartSpecification channelParts;
Dictionary actionParts;
Dictionary readOnlyNormalizedActionParts;
bool isReadOnly;
public ScopedMessagePartSpecification()
{
this.channelParts = new MessagePartSpecification();
this.actionParts = new Dictionary();
}
public ICollection Actions
{
get
{
return this.actionParts.Keys;
}
}
public MessagePartSpecification ChannelParts
{
get
{
return this.channelParts;
}
}
public bool IsReadOnly
{
get
{
return this.isReadOnly;
}
}
public ScopedMessagePartSpecification(ScopedMessagePartSpecification other)
: this()
{
if (other == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("other"));
this.channelParts.Union(other.channelParts);
if (other.actionParts != null)
{
foreach (string action in other.actionParts.Keys)
{
MessagePartSpecification p = new MessagePartSpecification();
p.Union(other.actionParts[action]);
this.actionParts[action] = p;
}
}
}
internal ScopedMessagePartSpecification(ScopedMessagePartSpecification other, bool newIncludeBody)
: this(other)
{
this.channelParts.IsBodyIncluded = newIncludeBody;
foreach (string action in this.actionParts.Keys)
this.actionParts[action].IsBodyIncluded = newIncludeBody;
}
public void AddParts(MessagePartSpecification parts)
{
if (parts == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("parts"));
ThrowIfReadOnly();
this.channelParts.Union(parts);
}
public void AddParts(MessagePartSpecification parts, string action)
{
if (action == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("action"));
if (parts == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("parts"));
ThrowIfReadOnly();
if (!this.actionParts.ContainsKey(action))
this.actionParts[action] = new MessagePartSpecification();
this.actionParts[action].Union(parts);
}
internal void AddParts(MessagePartSpecification parts, XmlDictionaryString action)
{
if (action == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("action"));
AddParts(parts, action.Value);
}
internal bool IsEmpty()
{
bool result;
if (!channelParts.IsEmpty())
{
result = false;
}
else
{
result = true;
foreach (string action in this.Actions)
{
MessagePartSpecification parts;
if (TryGetParts(action, true, out parts))
{
if (!parts.IsEmpty())
{
result = false;
break;
}
}
}
}
return result;
}
public bool TryGetParts(string action, bool excludeChannelScope, out MessagePartSpecification parts)
{
if (action == null)
action = MessageHeaders.WildcardAction;
parts = null;
if (this.isReadOnly)
{
if (this.readOnlyNormalizedActionParts.ContainsKey(action))
if (excludeChannelScope)
parts = this.actionParts[action];
else
parts = this.readOnlyNormalizedActionParts[action];
}
else if (this.actionParts.ContainsKey(action))
{
MessagePartSpecification p = new MessagePartSpecification();
p.Union(this.actionParts[action]);
if (!excludeChannelScope)
p.Union(this.channelParts);
parts = p;
}
return parts != null;
}
internal void CopyTo(ScopedMessagePartSpecification target)
{
if (target == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("target");
}
target.ChannelParts.IsBodyIncluded = this.ChannelParts.IsBodyIncluded;
foreach (XmlQualifiedName headerType in ChannelParts.HeaderTypes)
{
if (!target.channelParts.IsHeaderIncluded(headerType.Name, headerType.Namespace))
{
target.ChannelParts.HeaderTypes.Add(headerType);
}
}
foreach (string action in this.actionParts.Keys)
{
target.AddParts(this.actionParts[action], action);
}
}
public bool TryGetParts(string action, out MessagePartSpecification parts)
{
return this.TryGetParts(action, false, out parts);
}
public void MakeReadOnly()
{
if (!this.isReadOnly)
{
this.readOnlyNormalizedActionParts = new Dictionary();
foreach (string action in this.actionParts.Keys)
{
MessagePartSpecification p = new MessagePartSpecification();
p.Union(this.actionParts[action]);
p.Union(this.channelParts);
p.MakeReadOnly();
this.readOnlyNormalizedActionParts[action] = p;
}
this.isReadOnly = true;
}
}
void ThrowIfReadOnly()
{
if (this.isReadOnly)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HtmlForm.cs
- _SingleItemRequestCache.cs
- TextTreeDeleteContentUndoUnit.cs
- SourceExpressionException.cs
- AutomationProperties.cs
- ContainerVisual.cs
- HashAlgorithm.cs
- SymmetricAlgorithm.cs
- SoapCommonClasses.cs
- CommandBinding.cs
- Material.cs
- UIElement.cs
- CodeGen.cs
- PriorityRange.cs
- DictionaryTraceRecord.cs
- ErrorWebPart.cs
- DataTemplateKey.cs
- VersionValidator.cs
- FullTextState.cs
- RecognizedWordUnit.cs
- TextDecorationUnitValidation.cs
- ObjectStateFormatter.cs
- StreamFormatter.cs
- IntPtr.cs
- TypedElement.cs
- File.cs
- ByteRangeDownloader.cs
- IProducerConsumerCollection.cs
- ToolStripTextBox.cs
- ObjectDataSourceSelectingEventArgs.cs
- UriPrefixTable.cs
- Gdiplus.cs
- SQLChars.cs
- StrokeIntersection.cs
- PagerSettings.cs
- ObservableDictionary.cs
- IgnoreSection.cs
- HttpFileCollectionWrapper.cs
- Collection.cs
- VBCodeProvider.cs
- WasEndpointConfigContainer.cs
- ImageMetadata.cs
- Duration.cs
- Model3DCollection.cs
- RelationshipWrapper.cs
- SourceExpressionException.cs
- Visual.cs
- NavigationPropertyEmitter.cs
- WindowsRichEditRange.cs
- InstanceLockLostException.cs
- ArraySubsetEnumerator.cs
- WebConfigurationManager.cs
- CategoryValueConverter.cs
- OdbcConnection.cs
- ProfessionalColors.cs
- GradientBrush.cs
- StrongNameKeyPair.cs
- CopyCodeAction.cs
- InitializationEventAttribute.cs
- BrushValueSerializer.cs
- ManagedCodeMarkers.cs
- ConfigurationSectionGroupCollection.cs
- Control.cs
- ClientScriptManagerWrapper.cs
- LinqDataView.cs
- PathFigure.cs
- RoleBoolean.cs
- PenThread.cs
- WindowsListViewGroupHelper.cs
- ActionItem.cs
- ILGen.cs
- DockProviderWrapper.cs
- ListBoxAutomationPeer.cs
- AuthenticationSection.cs
- CellRelation.cs
- MonthChangedEventArgs.cs
- SqlDependencyListener.cs
- TextTrailingCharacterEllipsis.cs
- SqlBuffer.cs
- ToolboxDataAttribute.cs
- Literal.cs
- KeyInfo.cs
- EncoderNLS.cs
- EventBuilder.cs
- Delay.cs
- EntitySet.cs
- HttpMethodConstraint.cs
- XmlUnspecifiedAttribute.cs
- AsymmetricSignatureFormatter.cs
- TableLayoutStyleCollection.cs
- TextEditorCharacters.cs
- NumericExpr.cs
- SafeEventLogReadHandle.cs
- TrackBarRenderer.cs
- WebPartManager.cs
- DataSpaceManager.cs
- OrthographicCamera.cs
- AcceptorSessionSymmetricMessageSecurityProtocol.cs
- LiteralControl.cs
- ListSourceHelper.cs