Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Configuration / XmlElementElement.cs / 1 / XmlElementElement.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Configuration { using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Configuration; using System.Xml; using System.Security; public sealed partial class XmlElementElement : ConfigurationElement { public XmlElementElement() { } public XmlElementElement(XmlElement element) : this() { this.XmlElement = element; } public void Copy(XmlElementElement source) { if (this.IsReadOnly()) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigReadOnly))); } if (null == source) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("source"); } if (null != source.XmlElement) { this.XmlElement = (XmlElement)source.XmlElement.Clone(); } } ////// Critical - uses the critical helper SetIsPresent /// Safe - controls how/when SetIsPresent is used, not arbitrarily callable from PT (method is protected and class is sealed) /// [SecurityCritical, SecurityTreatAsSafe] protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey) { SetIsPresent(); DeserializeElementCore(reader); } private void DeserializeElementCore(XmlReader reader) { XmlDocument doc = new XmlDocument(); this.XmlElement = (XmlElement)doc.ReadNode(reader); } internal void ResetInternal(XmlElementElement element) { this.Reset(element); } ////// Critical - calls ConfigurationHelpers.SetIsPresent which elevates in order to set a property /// Safe - only passes 'this', does not let caller influence parameter /// [SecurityCritical] void SetIsPresent() { ConfigurationHelpers.SetIsPresent(this); } protected override bool SerializeToXmlElement(XmlWriter writer, String elementName) { bool dataToWrite = this.XmlElement != null; if (dataToWrite && writer != null) { if (!String.Equals(elementName, ConfigurationStrings.XmlElement, StringComparison.Ordinal)) { writer.WriteStartElement(elementName); } using (XmlNodeReader reader = new XmlNodeReader(this.XmlElement)) { writer.WriteNode(reader, false); } if (!String.Equals(elementName, ConfigurationStrings.XmlElement, StringComparison.Ordinal)) { writer.WriteEndElement(); } } return dataToWrite; } protected override void PostDeserialize() { this.Validate(); base.PostDeserialize(); } void Validate() { if (this.XmlElement == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(SR.GetString(SR.ConfigXmlElementMustBeSet), this.ElementInformation.Source, this.ElementInformation.LineNumber)); } } [ConfigurationProperty(ConfigurationStrings.XmlElement, DefaultValue = null, Options = ConfigurationPropertyOptions.IsKey)] public XmlElement XmlElement { get { return (XmlElement)base[ConfigurationStrings.XmlElement]; } set { base[ConfigurationStrings.XmlElement] = value; } } } } // 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
- ButtonStandardAdapter.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- DataGridParentRows.cs
- TextSpan.cs
- QueuePathDialog.cs
- StateInitialization.cs
- ListBoxItemAutomationPeer.cs
- Emitter.cs
- BaseAppDomainProtocolHandler.cs
- ServicePoint.cs
- WebRequestModuleElement.cs
- NavigationProgressEventArgs.cs
- DragDrop.cs
- TargetConverter.cs
- FixedFlowMap.cs
- GAC.cs
- ToolboxDataAttribute.cs
- MemoryFailPoint.cs
- TimelineGroup.cs
- XsltConvert.cs
- BulletChrome.cs
- _KerberosClient.cs
- CodeArrayCreateExpression.cs
- FixedSOMFixedBlock.cs
- InternalDuplexChannelFactory.cs
- OpCodes.cs
- _SpnDictionary.cs
- ConfigXmlText.cs
- MetadataItemSerializer.cs
- ParameterCollection.cs
- PersonalizationDictionary.cs
- BooleanAnimationUsingKeyFrames.cs
- SqlCommandSet.cs
- LogFlushAsyncResult.cs
- DesignTimeVisibleAttribute.cs
- ApplicationException.cs
- TreeViewHitTestInfo.cs
- CharacterMetricsDictionary.cs
- MarkupCompiler.cs
- TypeConverterHelper.cs
- CheckedPointers.cs
- PackUriHelper.cs
- MediaElementAutomationPeer.cs
- XmlnsCompatibleWithAttribute.cs
- ItemChangedEventArgs.cs
- SafeEventLogWriteHandle.cs
- Debugger.cs
- x509store.cs
- TimeSpan.cs
- PackageProperties.cs
- Mutex.cs
- ObjectDataSourceSelectingEventArgs.cs
- CounterCreationDataCollection.cs
- SafeProcessHandle.cs
- HttpClientCertificate.cs
- SamlAssertionKeyIdentifierClause.cs
- MiniConstructorInfo.cs
- DockPatternIdentifiers.cs
- DeferredElementTreeState.cs
- TranslateTransform.cs
- WebPartHelpVerb.cs
- HttpListenerRequestUriBuilder.cs
- BindingBase.cs
- DesignerProperties.cs
- PriorityBinding.cs
- Delegate.cs
- EnumMember.cs
- LinqDataSourceStatusEventArgs.cs
- TakeQueryOptionExpression.cs
- XmlSchemaExporter.cs
- DeploymentSection.cs
- ColorTranslator.cs
- HttpRequestCacheValidator.cs
- OverlappedAsyncResult.cs
- FloatSumAggregationOperator.cs
- AdornedElementPlaceholder.cs
- TcpProcessProtocolHandler.cs
- PrimitiveCodeDomSerializer.cs
- DefaultClaimSet.cs
- Win32.cs
- QualifiedCellIdBoolean.cs
- ScrollProviderWrapper.cs
- SecurityIdentifierElement.cs
- PackWebRequest.cs
- StylusDevice.cs
- FillRuleValidation.cs
- AppDomainManager.cs
- ResourceProperty.cs
- PolyLineSegment.cs
- ToolboxBitmapAttribute.cs
- BrowserTree.cs
- ClearTypeHintValidation.cs
- SQLInt16Storage.cs
- TextStore.cs
- RemotingService.cs
- KeyedCollection.cs
- CryptoProvider.cs
- TextCharacters.cs
- X509SecurityTokenAuthenticator.cs
- ChooseAction.cs