Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / XmlSerializableWriter.cs / 1305376 / XmlSerializableWriter.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Runtime.Serialization { using System; using System.Xml; internal class XmlSerializableWriter : XmlWriter { XmlWriter xmlWriter; int depth = 0; object obj; internal void BeginWrite(XmlWriter xmlWriter, object obj) { depth = 0; this.xmlWriter = xmlWriter; this.obj = obj; } internal void EndWrite() { if (depth != 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.IXmlSerializableMissingEndElements, (obj == null ? string.Empty : DataContract.GetClrTypeFullName(obj.GetType()))))); this.obj = null; } public override void WriteStartDocument() { if (WriteState == WriteState.Start) xmlWriter.WriteStartDocument(); } public override void WriteEndDocument() { xmlWriter.WriteEndDocument(); } public override void WriteStartDocument(bool standalone) { if (WriteState == WriteState.Start) xmlWriter.WriteStartDocument(standalone); } public override void WriteDocType(string name, string pubid, string sysid, string subset) { // XmlSerializer does not write doc type } public override void WriteStartElement(string prefix, string localName, string ns) { xmlWriter.WriteStartElement(prefix, localName, ns); depth++; } public override void WriteEndElement() { if (depth == 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.IXmlSerializableWritePastSubTree, (obj == null ? string.Empty : DataContract.GetClrTypeFullName(obj.GetType()))))); xmlWriter.WriteEndElement(); depth--; } public override void WriteFullEndElement() { if (depth == 0) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.IXmlSerializableWritePastSubTree, (obj == null ? string.Empty : DataContract.GetClrTypeFullName(obj.GetType()))))); xmlWriter.WriteFullEndElement(); depth--; } public override void Close() { throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.IXmlSerializableIllegalOperation))); } public override void WriteStartAttribute(string prefix, string localName, string ns) { xmlWriter.WriteStartAttribute(prefix, localName, ns); } public override void WriteEndAttribute() {xmlWriter.WriteEndAttribute();} public override void WriteCData(string text) {xmlWriter.WriteCData(text);} public override void WriteComment(string text) {xmlWriter.WriteComment(text);} public override void WriteProcessingInstruction(string name, string text) {xmlWriter.WriteProcessingInstruction(name, text);} public override void WriteEntityRef(string name) {xmlWriter.WriteEntityRef(name);} public override void WriteCharEntity(char ch) {xmlWriter.WriteCharEntity(ch);} public override void WriteWhitespace(string ws) {xmlWriter.WriteWhitespace(ws);} public override void WriteString(string text) {xmlWriter.WriteString(text);} public override void WriteSurrogateCharEntity(char lowChar, char highChar){xmlWriter.WriteSurrogateCharEntity(lowChar, highChar);} public override void WriteChars(Char[] buffer, int index, int count) {xmlWriter.WriteChars(buffer, index, count);} public override void WriteRaw(Char[] buffer, int index, int count) {xmlWriter.WriteRaw(buffer, index, count);} public override void WriteRaw(String data) {xmlWriter.WriteRaw(data);} public override void WriteBase64(byte[] buffer, int index, int count) {xmlWriter.WriteBase64(buffer, index, count);} public override void WriteBinHex(byte[] buffer, int index, int count) {xmlWriter.WriteBinHex(buffer, index, count);} public override WriteState WriteState { get { return xmlWriter.WriteState; } } public override void Flush() { xmlWriter.Flush(); } public override void WriteName(string name) {xmlWriter.WriteName(name);} public override void WriteQualifiedName(string localName, string ns) {xmlWriter.WriteQualifiedName(localName, ns);} public override string LookupPrefix(string ns) {return xmlWriter.LookupPrefix(ns);} public override XmlSpace XmlSpace { get { return xmlWriter.XmlSpace; } } public override string XmlLang { get { return xmlWriter.XmlLang; } } public override void WriteNmToken(string name) {xmlWriter.WriteNmToken(name);} } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- VerificationException.cs
- EmulateRecognizeCompletedEventArgs.cs
- DockAndAnchorLayout.cs
- PersonalizationDictionary.cs
- CompiledELinqQueryState.cs
- CmsUtils.cs
- XmlSchemaSimpleType.cs
- DeflateEmulationStream.cs
- AppDomainUnloadedException.cs
- RuleInfoComparer.cs
- RefreshEventArgs.cs
- HtmlSelect.cs
- MTConfigUtil.cs
- TokenizerHelper.cs
- SkewTransform.cs
- QueryContinueDragEvent.cs
- Schema.cs
- DataGridParentRows.cs
- SchemaDeclBase.cs
- ListBase.cs
- documentation.cs
- XmlToDatasetMap.cs
- WebException.cs
- BooleanAnimationUsingKeyFrames.cs
- AtomMaterializerLog.cs
- SqlProfileProvider.cs
- AxHost.cs
- IsolationInterop.cs
- DataTableMappingCollection.cs
- MsmqIntegrationBindingElement.cs
- ToolBarTray.cs
- AssociativeAggregationOperator.cs
- NoResizeSelectionBorderGlyph.cs
- ValidatorCollection.cs
- ObfuscationAttribute.cs
- TypographyProperties.cs
- Win32KeyboardDevice.cs
- TreeNodeStyleCollection.cs
- QuadraticBezierSegment.cs
- SourceFileBuildProvider.cs
- MimeTypeMapper.cs
- CodeTypeParameter.cs
- RtfNavigator.cs
- TreeNodeEventArgs.cs
- PenContext.cs
- SelectorAutomationPeer.cs
- HttpModulesSection.cs
- ErrorFormatter.cs
- DisplayMemberTemplateSelector.cs
- ButtonBase.cs
- ContextInformation.cs
- ActiveXSite.cs
- AliasGenerator.cs
- EventListener.cs
- EventMap.cs
- Image.cs
- DiffuseMaterial.cs
- XmlEncoding.cs
- CommandBinding.cs
- AdPostCacheSubstitution.cs
- PerformanceCounterPermissionEntry.cs
- RepeatButton.cs
- SynchronizedDispatch.cs
- CatalogZoneBase.cs
- VectorCollectionValueSerializer.cs
- DataBoundControl.cs
- ReceiveContext.cs
- SchemaElementLookUpTable.cs
- ListControl.cs
- EncryptedPackageFilter.cs
- ReadOnlyDataSourceView.cs
- XmlSchemaValidator.cs
- exports.cs
- SqlConnection.cs
- ArcSegment.cs
- Vector3DValueSerializer.cs
- PropVariant.cs
- ResXResourceWriter.cs
- ProfessionalColors.cs
- AttachedAnnotationChangedEventArgs.cs
- HttpDateParse.cs
- ToolboxItemCollection.cs
- EntityConnectionStringBuilderItem.cs
- ImpersonateTokenRef.cs
- EncoderExceptionFallback.cs
- RadioButtonList.cs
- CellConstant.cs
- TagMapInfo.cs
- ItemChangedEventArgs.cs
- RbTree.cs
- WebPartCloseVerb.cs
- FontUnitConverter.cs
- ParallelTimeline.cs
- Delegate.cs
- TileBrush.cs
- HostedHttpRequestAsyncResult.cs
- SerializationObjectManager.cs
- MenuDesigner.cs
- EntityConnectionStringBuilder.cs
- BitmapSizeOptions.cs