Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / XPathMessageFilterElement.cs / 1 / XPathMessageFilterElement.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Configuration { using System; using System.Configuration; using System.Globalization; using System.IO; using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; using System.Xml; using System.Xml.Serialization; using System.Text; public sealed partial class XPathMessageFilterElement : ConfigurationElement { const int DefaultNodeQuota = 1000; [ConfigurationProperty(ConfigurationStrings.Filter, DefaultValue = null, Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)] public XPathMessageFilter Filter { get { return (XPathMessageFilter)base[ConfigurationStrings.Filter]; } set { base[ConfigurationStrings.Filter] = value; } } protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey) { StringBuilder filterStringBuilder = new StringBuilder(); string nodeQuotaStringValue = String.Empty; XmlWriterSettings settings = new XmlWriterSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.OmitXmlDeclaration = false; using (XmlWriter tempWriter = XmlWriter.Create(filterStringBuilder, settings)) { tempWriter.WriteStartElement(reader.Name); if (0 < reader.AttributeCount) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); if (reader.Name.Equals(ConfigurationStrings.NodeQuota, StringComparison.Ordinal)) { nodeQuotaStringValue = reader.Value; } else { if (reader.Name.Contains(":")) { string[] attributeName = reader.Name.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); tempWriter.WriteAttributeString(attributeName[0], attributeName[1], null, reader.Value); } else { tempWriter.WriteAttributeString(reader.Name, reader.Value); } } } reader.MoveToElement(); } string filterString = reader.ReadString(); filterString = filterString.Trim(); if (String.IsNullOrEmpty(filterString)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.GetString(SR.ConfigXPathFilterMustNotBeEmpty))); } tempWriter.WriteString(filterString); tempWriter.WriteEndElement(); } XPathMessageFilter filter = null; using (StringReader stringReader = new StringReader(filterStringBuilder.ToString())) { using (XmlReader tempReader = XmlReader.Create(stringReader)) { filter = new XPathMessageFilter(tempReader); } } if (null != filter) { if (!String.IsNullOrEmpty(nodeQuotaStringValue)) { filter.NodeQuota = int.Parse(nodeQuotaStringValue, CultureInfo.CurrentCulture); } else { filter.NodeQuota = XPathMessageFilterElement.DefaultNodeQuota; } } this.Filter = filter; } protected override bool SerializeToXmlElement(XmlWriter writer, String elementName) { bool dataToWrite = this.Filter != null; if (dataToWrite && writer != null) { //this.Filter.WriteXPathTo(writer, null, elementName, null, true); writer.WriteStartElement(elementName); writer.WriteAttributeString(ConfigurationStrings.NodeQuota, Filter.NodeQuota.ToString(NumberFormatInfo.CurrentInfo)); StringBuilder filterStringBuilder = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.OmitXmlDeclaration = false; using (XmlWriter tempWriter = XmlWriter.Create(filterStringBuilder, settings)) { this.Filter.WriteXPathTo(tempWriter, null, elementName, null, true); } using(StringReader stringReader = new StringReader(filterStringBuilder.ToString())) { using (XmlReader tempReader = XmlReader.Create(stringReader)) { if (tempReader.Read()) { if (0 < tempReader.AttributeCount) { for (int i = 0; i < tempReader.AttributeCount; i++) { tempReader.MoveToAttribute(i); writer.WriteAttributeString(tempReader.Name, tempReader.Value); } tempReader.MoveToElement(); } writer.WriteString(tempReader.ReadString()); } } } writer.WriteEndElement(); } return dataToWrite; } } } // 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
- XmlSchemaSimpleContentRestriction.cs
- BooleanAnimationUsingKeyFrames.cs
- Transform.cs
- SyntaxCheck.cs
- PartEditor.cs
- ConfigurationValues.cs
- WbemException.cs
- SmtpNtlmAuthenticationModule.cs
- ConfigurationStrings.cs
- XmlDataImplementation.cs
- CharEntityEncoderFallback.cs
- InvalidProgramException.cs
- ControlBindingsConverter.cs
- IndexedString.cs
- SyndicationSerializer.cs
- ContextMenuAutomationPeer.cs
- CssClassPropertyAttribute.cs
- OrderedDictionaryStateHelper.cs
- EventLog.cs
- FieldBuilder.cs
- VirtualizedItemProviderWrapper.cs
- MulticastNotSupportedException.cs
- EventLogTraceListener.cs
- FontSourceCollection.cs
- SerializationSectionGroup.cs
- TextRangeAdaptor.cs
- MouseOverProperty.cs
- BitmapSizeOptions.cs
- FontUnit.cs
- ElementUtil.cs
- InvariantComparer.cs
- DataGridViewColumnEventArgs.cs
- CompModSwitches.cs
- TemplateEditingVerb.cs
- HtmlImage.cs
- ObjectDataSourceSelectingEventArgs.cs
- ConfigurationManagerInternalFactory.cs
- SyntaxCheck.cs
- Publisher.cs
- SmtpNtlmAuthenticationModule.cs
- SessionState.cs
- DeferredElementTreeState.cs
- DashStyle.cs
- WeakReferenceKey.cs
- MediaPlayerState.cs
- Validator.cs
- MailDefinition.cs
- PropertyMapper.cs
- RangeExpression.cs
- PnrpPeerResolverBindingElement.cs
- DefaultTextStore.cs
- CodeTypeConstructor.cs
- Visitor.cs
- SqlWebEventProvider.cs
- SmiEventStream.cs
- RichTextBox.cs
- DoubleCollectionValueSerializer.cs
- ColumnMapVisitor.cs
- x509utils.cs
- TokenFactoryBase.cs
- WmpBitmapEncoder.cs
- EntityDataSourceContextCreatedEventArgs.cs
- RightsManagementEncryptedStream.cs
- TransactionTraceIdentifier.cs
- CookieHandler.cs
- oledbmetadatacolumnnames.cs
- AccessibleObject.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- DesignerCommandSet.cs
- DesignerAdapterUtil.cs
- HeaderedItemsControl.cs
- DynamicEndpointElement.cs
- AgileSafeNativeMemoryHandle.cs
- ActivityUtilities.cs
- SchemaImporterExtensionsSection.cs
- WorkerRequest.cs
- TextureBrush.cs
- DeferredElementTreeState.cs
- ApplicationInfo.cs
- SQLBytesStorage.cs
- AttachedPropertiesService.cs
- DbCommandDefinition.cs
- ThreadPool.cs
- XmlException.cs
- GridViewRowPresenter.cs
- ManipulationDeltaEventArgs.cs
- HandleValueEditor.cs
- ETagAttribute.cs
- SplineKeyFrames.cs
- StyleCollectionEditor.cs
- PasswordRecovery.cs
- ServiceEndpointCollection.cs
- DataSourceProvider.cs
- DuplicateWaitObjectException.cs
- Boolean.cs
- diagnosticsswitches.cs
- InfoCardBaseException.cs
- TextBreakpoint.cs
- SortFieldComparer.cs
- TTSEngineProxy.cs