Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / MessagePartSpecification.cs / 1 / MessagePartSpecification.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Security
{
using System.Xml;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
public class MessagePartSpecification
{
List headerTypes;
bool isBodyIncluded;
bool isReadOnly;
static MessagePartSpecification noParts;
public ICollection HeaderTypes
{
get
{
if (headerTypes == null)
{
headerTypes = new List();
}
if (isReadOnly)
{
return new ReadOnlyCollection(headerTypes);
}
else
{
return headerTypes;
}
}
}
internal bool HasHeaders
{
get { return this.headerTypes != null && this.headerTypes.Count > 0; }
}
public bool IsBodyIncluded
{
get
{
return this.isBodyIncluded;
}
set
{
if (isReadOnly)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
this.isBodyIncluded = value;
}
}
public bool IsReadOnly
{
get
{
return this.isReadOnly;
}
}
static public MessagePartSpecification NoParts
{
get
{
if (noParts == null)
{
MessagePartSpecification parts = new MessagePartSpecification();
parts.MakeReadOnly();
noParts = parts;
}
return noParts;
}
}
public void Clear()
{
if (isReadOnly)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
if (this.headerTypes != null)
this.headerTypes.Clear();
this.isBodyIncluded = false;
}
public void Union(MessagePartSpecification specification)
{
if (isReadOnly)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
if (specification == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("specification");
this.isBodyIncluded |= specification.IsBodyIncluded;
List headerTypes = specification.headerTypes;
if (headerTypes != null && headerTypes.Count > 0)
{
if (this.headerTypes == null)
{
this.headerTypes = new List(headerTypes.Count);
}
for (int i = 0; i < headerTypes.Count; i++)
{
XmlQualifiedName qname = headerTypes[i];
this.headerTypes.Add(qname);
}
}
}
public void MakeReadOnly()
{
if (isReadOnly)
return;
if (this.headerTypes != null)
{
List noDuplicates = new List(headerTypes.Count);
for (int i = 0; i < headerTypes.Count; i++)
{
XmlQualifiedName qname = headerTypes[i];
if (qname != null)
{
bool include = true;
for (int j = 0; j < noDuplicates.Count; j++)
{
XmlQualifiedName qname1 = noDuplicates[j];
if (qname.Name == qname1.Name && qname.Namespace == qname1.Namespace)
{
include = false;
break;
}
}
if (include)
noDuplicates.Add(qname);
}
}
this.headerTypes = noDuplicates;
}
this.isReadOnly = true;
}
public MessagePartSpecification()
{
// empty
}
public MessagePartSpecification(bool isBodyIncluded)
{
this.isBodyIncluded = isBodyIncluded;
}
public MessagePartSpecification(params XmlQualifiedName[] headerTypes)
: this(false, headerTypes)
{
// empty
}
public MessagePartSpecification(bool isBodyIncluded, params XmlQualifiedName[] headerTypes)
{
this.isBodyIncluded = isBodyIncluded;
if (headerTypes != null && headerTypes.Length > 0)
{
this.headerTypes = new List(headerTypes.Length);
for (int i = 0; i < headerTypes.Length; i++)
{
this.headerTypes.Add(headerTypes[i]);
}
}
}
internal bool IsHeaderIncluded(MessageHeader header)
{
if (header == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("header");
return IsHeaderIncluded(header.Name, header.Namespace);
}
internal bool IsHeaderIncluded(string name, string ns)
{
if (name == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
if (ns == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("ns");
if (this.headerTypes != null)
{
for (int i = 0; i < this.headerTypes.Count; i++)
{
XmlQualifiedName qname = this.headerTypes[i];
if (qname.Name == name && qname.Namespace == ns)
{
return true;
}
}
}
return false;
}
internal bool IsEmpty()
{
if (this.headerTypes != null && this.headerTypes.Count > 0)
return false;
return !this.IsBodyIncluded;
}
}
}
// 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
- Array.cs
- MergeFailedEvent.cs
- ListChangedEventArgs.cs
- LifetimeServices.cs
- PageContentAsyncResult.cs
- BufferedReadStream.cs
- CalendarDay.cs
- StackOverflowException.cs
- SHA256Managed.cs
- TextRunTypographyProperties.cs
- Stroke.cs
- DataReceivedEventArgs.cs
- IndentTextWriter.cs
- DataServiceRequestException.cs
- Debug.cs
- ApplicationServicesHostFactory.cs
- UnsafeNativeMethods.cs
- DeleteMemberBinder.cs
- Lasso.cs
- VisualTreeHelper.cs
- ResourceFallbackManager.cs
- DateTimeSerializationSection.cs
- UIPropertyMetadata.cs
- BinaryConverter.cs
- DataBoundLiteralControl.cs
- ResizingMessageFilter.cs
- SqlStream.cs
- XmlSchemaType.cs
- TextLineResult.cs
- XmlIlGenerator.cs
- DispatcherExceptionEventArgs.cs
- ImpersonationContext.cs
- SliderAutomationPeer.cs
- WorkflowRuntimeElement.cs
- SoapExtensionTypeElementCollection.cs
- TypedOperationInfo.cs
- UnsafeNativeMethods.cs
- ParseChildrenAsPropertiesAttribute.cs
- ModuleBuilder.cs
- Internal.cs
- Serializer.cs
- DataGridViewBindingCompleteEventArgs.cs
- MessageRpc.cs
- TemplateField.cs
- ListViewInsertEventArgs.cs
- UrlMappingsModule.cs
- SqlConnectionHelper.cs
- SmtpFailedRecipientsException.cs
- DocumentCollection.cs
- SubMenuStyle.cs
- ResourceDescriptionAttribute.cs
- Activity.cs
- XamlWrapperReaders.cs
- _ConnectionGroup.cs
- DropSource.cs
- CounterCreationDataConverter.cs
- ButtonBaseAdapter.cs
- XsdCachingReader.cs
- WebPartDisplayModeEventArgs.cs
- RuntimeVariablesExpression.cs
- CounterSetInstance.cs
- ListBoxItemWrapperAutomationPeer.cs
- MsmqIntegrationChannelFactory.cs
- SqlDelegatedTransaction.cs
- CompleteWizardStep.cs
- GeneralTransform3DTo2D.cs
- Trace.cs
- PageAsyncTask.cs
- XPathNodePointer.cs
- CompositeActivityTypeDescriptorProvider.cs
- ListenUriMode.cs
- WizardDesigner.cs
- SynchronousReceiveElement.cs
- WorkflowApplicationCompletedException.cs
- EventlogProvider.cs
- DbExpressionBuilder.cs
- ConfigurationManagerHelper.cs
- SafeProcessHandle.cs
- SkinBuilder.cs
- OdbcEnvironment.cs
- nulltextcontainer.cs
- StyleCollection.cs
- EventListenerClientSide.cs
- EventLogPermissionEntryCollection.cs
- BinaryConverter.cs
- CrossContextChannel.cs
- TypeEnumerableViewSchema.cs
- HandledEventArgs.cs
- MergablePropertyAttribute.cs
- TargetConverter.cs
- BrowserCapabilitiesCompiler.cs
- TrustLevel.cs
- GetParentChain.cs
- XmlAttributeAttribute.cs
- NumberFormatter.cs
- EventLogEntryCollection.cs
- EncryptedType.cs
- DelimitedListTraceListener.cs
- IntegerFacetDescriptionElement.cs
- DesignTimeData.cs