Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Serialization / System / Runtime / Serialization / XmlSerializableServices.cs / 1305376 / XmlSerializableServices.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime.Serialization
{
using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
public static class XmlSerializableServices
{
[Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - Static fields are marked SecurityCritical or readonly to prevent"
+ " data from being modified or leaked to other components in appdomain.")]
internal static readonly string ReadNodesMethodName = "ReadNodes";
public static XmlNode[] ReadNodes(XmlReader xmlReader)
{
if (xmlReader == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
XmlDocument doc = new XmlDocument();
List nodeList = new List();
if (xmlReader.MoveToFirstAttribute())
{
do
{
if (IsValidAttribute(xmlReader))
{
XmlNode node = doc.ReadNode(xmlReader);
if (node == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
nodeList.Add(node);
}
} while (xmlReader.MoveToNextAttribute());
}
xmlReader.MoveToElement();
if (!xmlReader.IsEmptyElement)
{
int startDepth = xmlReader.Depth;
xmlReader.Read();
while (xmlReader.Depth > startDepth && xmlReader.NodeType != XmlNodeType.EndElement)
{
XmlNode node = doc.ReadNode(xmlReader);
if (node == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
nodeList.Add(node);
}
}
return nodeList.ToArray();
}
private static bool IsValidAttribute(XmlReader xmlReader)
{
return xmlReader.NamespaceURI != Globals.SerializationNamespace &&
xmlReader.NamespaceURI != Globals.SchemaInstanceNamespace &&
xmlReader.Prefix != "xmlns" &&
xmlReader.LocalName != "xmlns";
}
internal static string WriteNodesMethodName = "WriteNodes";
public static void WriteNodes(XmlWriter xmlWriter, XmlNode[] nodes)
{
if (xmlWriter == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlWriter");
if (nodes != null)
for(int i=0;i nodeList = new List();
if (xmlReader.MoveToFirstAttribute())
{
do
{
if (IsValidAttribute(xmlReader))
{
XmlNode node = doc.ReadNode(xmlReader);
if (node == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
nodeList.Add(node);
}
} while (xmlReader.MoveToNextAttribute());
}
xmlReader.MoveToElement();
if (!xmlReader.IsEmptyElement)
{
int startDepth = xmlReader.Depth;
xmlReader.Read();
while (xmlReader.Depth > startDepth && xmlReader.NodeType != XmlNodeType.EndElement)
{
XmlNode node = doc.ReadNode(xmlReader);
if (node == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
nodeList.Add(node);
}
}
return nodeList.ToArray();
}
private static bool IsValidAttribute(XmlReader xmlReader)
{
return xmlReader.NamespaceURI != Globals.SerializationNamespace &&
xmlReader.NamespaceURI != Globals.SchemaInstanceNamespace &&
xmlReader.Prefix != "xmlns" &&
xmlReader.LocalName != "xmlns";
}
internal static string WriteNodesMethodName = "WriteNodes";
public static void WriteNodes(XmlWriter xmlWriter, XmlNode[] nodes)
{
if (xmlWriter == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlWriter");
if (nodes != null)
for(int i=0;i
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ListBindingHelper.cs
- SerializerProvider.cs
- HttpProfileBase.cs
- CssStyleCollection.cs
- Trace.cs
- EnumerableCollectionView.cs
- LogRecordSequence.cs
- SystemColorTracker.cs
- PKCS1MaskGenerationMethod.cs
- ManifestResourceInfo.cs
- DesignBindingEditor.cs
- UrlMapping.cs
- DataGridView.cs
- WeakReferenceKey.cs
- QueryableFilterRepeater.cs
- ObjRef.cs
- CircleHotSpot.cs
- ToolStripSplitStackLayout.cs
- EntitySqlQueryCacheEntry.cs
- QilTypeChecker.cs
- CalendarAutomationPeer.cs
- DocumentViewerConstants.cs
- WebPartMenuStyle.cs
- MenuCommands.cs
- IriParsingElement.cs
- CodeAttributeDeclaration.cs
- ToolStripManager.cs
- webbrowsersite.cs
- Hash.cs
- selecteditemcollection.cs
- SessionStateItemCollection.cs
- DispatcherEventArgs.cs
- Encoder.cs
- CorePropertiesFilter.cs
- AttachedPropertyBrowsableAttribute.cs
- SessionStateContainer.cs
- TextReader.cs
- ServicePointManagerElement.cs
- SystemSounds.cs
- httpapplicationstate.cs
- BitFlagsGenerator.cs
- ExpressionsCollectionEditor.cs
- AttachedPropertyMethodSelector.cs
- VariableElement.cs
- HttpEncoder.cs
- BaseContextMenu.cs
- UIElement3D.cs
- InputDevice.cs
- ConcurrentStack.cs
- GenericTextProperties.cs
- _CacheStreams.cs
- EventMappingSettings.cs
- SymmetricKeyWrap.cs
- UserPreferenceChangingEventArgs.cs
- TraceHandler.cs
- QilNode.cs
- DashStyle.cs
- ExtensionDataReader.cs
- XmlSchemaExternal.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- SqlSelectStatement.cs
- HttpResponse.cs
- PropertyStore.cs
- TextParagraphCache.cs
- UnsafeCollabNativeMethods.cs
- MatrixConverter.cs
- MenuItem.cs
- WorkflowRuntime.cs
- Debug.cs
- SwitchAttribute.cs
- ButtonBaseAutomationPeer.cs
- GeneralTransformGroup.cs
- SelfIssuedAuthRSAPKCS1SignatureFormatter.cs
- ILGenerator.cs
- QilStrConcat.cs
- Int64Converter.cs
- QuaternionAnimation.cs
- EntityRecordInfo.cs
- ViewSimplifier.cs
- DrawingImage.cs
- DataGridViewTextBoxEditingControl.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- TypeAccessException.cs
- SQLInt32Storage.cs
- OrderPreservingMergeHelper.cs
- ListItemViewAttribute.cs
- metadatamappinghashervisitor.cs
- ThumbAutomationPeer.cs
- XPathDocumentIterator.cs
- KerberosReceiverSecurityToken.cs
- RemoveFromCollection.cs
- FontDifferentiator.cs
- EmptyTextWriter.cs
- ValidationError.cs
- NumberFunctions.cs
- CallSiteOps.cs
- ChtmlImageAdapter.cs
- XmlNavigatorFilter.cs
- FunctionImportElement.cs
- ManifestSignedXml.cs