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
- CellParagraph.cs
- HtmlElementEventArgs.cs
- HyperLinkStyle.cs
- PropertyInformation.cs
- WebPartDeleteVerb.cs
- XmlElementCollection.cs
- WebMessageFormatHelper.cs
- LogLogRecord.cs
- ModelToObjectValueConverter.cs
- ProcessHostServerConfig.cs
- StrokeNode.cs
- QilTargetType.cs
- EUCJPEncoding.cs
- TypeConverter.cs
- ConfigurationLocation.cs
- StructuralCache.cs
- DynamicILGenerator.cs
- DataGridViewRowPrePaintEventArgs.cs
- ProfileSettings.cs
- ComPlusThreadInitializer.cs
- HttpRequest.cs
- SystemWebCachingSectionGroup.cs
- EditorPartCollection.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- ProtocolsConfiguration.cs
- GridItemPattern.cs
- Odbc32.cs
- OpenTypeLayoutCache.cs
- UnsafeNetInfoNativeMethods.cs
- CurrencyManager.cs
- DateTimeConstantAttribute.cs
- RegexRunner.cs
- ColorConverter.cs
- LinqToSqlWrapper.cs
- ActivationArguments.cs
- WebPartPersonalization.cs
- HashStream.cs
- FontNameConverter.cs
- GC.cs
- ApplicationException.cs
- GenerateTemporaryAssemblyTask.cs
- DesignerOptionService.cs
- ConfigurationProperty.cs
- PathSegment.cs
- SmtpCommands.cs
- SafeTokenHandle.cs
- mansign.cs
- OperationDescriptionCollection.cs
- Overlapped.cs
- Visual3D.cs
- ManagedWndProcTracker.cs
- FormViewPageEventArgs.cs
- CustomValidator.cs
- ValueUtilsSmi.cs
- ProfileProvider.cs
- SequenceNumber.cs
- StatusBarPanelClickEvent.cs
- XmlCharType.cs
- SchemaUtility.cs
- COM2ExtendedUITypeEditor.cs
- UInt64Storage.cs
- KeyGestureValueSerializer.cs
- OleDbFactory.cs
- HttpChannelHelper.cs
- CombinedGeometry.cs
- BadImageFormatException.cs
- AccessDataSource.cs
- DbgUtil.cs
- Int32Storage.cs
- FileDialog.cs
- DesignTimeTemplateParser.cs
- DataServiceHostWrapper.cs
- ConstructorNeedsTagAttribute.cs
- ApplicationSecurityManager.cs
- BaseCAMarshaler.cs
- CellCreator.cs
- BamlLocalizationDictionary.cs
- ObjectDataSourceStatusEventArgs.cs
- ObjectQuery_EntitySqlExtensions.cs
- RegionData.cs
- InvokePattern.cs
- ListViewDataItem.cs
- EventDescriptor.cs
- ColorMap.cs
- AuthenticationModulesSection.cs
- FileDataSourceCache.cs
- StringFunctions.cs
- DataGridViewColumnHeaderCell.cs
- ProfileProvider.cs
- PriorityQueue.cs
- XmlSerializerOperationBehavior.cs
- ColorConverter.cs
- ConfigDefinitionUpdates.cs
- QilXmlReader.cs
- XmlWhitespace.cs
- FormView.cs
- PopupRootAutomationPeer.cs
- QueryInterceptorAttribute.cs
- SponsorHelper.cs
- AdapterDictionary.cs