Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Runtime / Serialization / SerializationInfoEnumerator.cs / 1 / SerializationInfoEnumerator.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*============================================================
**
** Class: SerializationInfoEnumerator
**
**
** Purpose: A formatter-friendly mechanism for walking all of
** the data in a SerializationInfo. Follows the IEnumerator
** mechanism from Collections.
**
**
============================================================*/
namespace System.Runtime.Serialization {
using System;
using System.Collections;
//
// The tuple returned by SerializationInfoEnumerator.Current.
//
[System.Runtime.InteropServices.ComVisible(true)]
public struct SerializationEntry {
private Type m_type;
private Object m_value;
private String m_name;
public Object Value {
get {
return m_value;
}
}
public String Name {
get {
return m_name;
}
}
public Type ObjectType {
get {
return m_type;
}
}
internal SerializationEntry(String entryName, Object entryValue, Type entryType) {
m_value = entryValue;
m_name = entryName;
m_type = entryType;
}
}
//
// A simple enumerator over the values stored in the SerializationInfo.
// This does not snapshot the values, it just keeps pointers to the
// member variables of the SerializationInfo that created it.
//
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class SerializationInfoEnumerator : IEnumerator {
String[] m_members;
Object[] m_data;
Type[] m_types;
int m_numItems;
int m_currItem;
bool m_current;
internal SerializationInfoEnumerator(String[] members, Object[] info, Type[] types, int numItems) {
BCLDebug.Assert(members!=null, "[SerializationInfoEnumerator.ctor]members!=null");
BCLDebug.Assert(info!=null, "[SerializationInfoEnumerator.ctor]info!=null");
BCLDebug.Assert(types!=null, "[SerializationInfoEnumerator.ctor]types!=null");
BCLDebug.Assert(numItems>=0, "[SerializationInfoEnumerator.ctor]numItems>=0");
BCLDebug.Assert(members.Length>=numItems, "[SerializationInfoEnumerator.ctor]members.Length>=numItems");
BCLDebug.Assert(info.Length>=numItems, "[SerializationInfoEnumerator.ctor]info.Length>=numItems");
BCLDebug.Assert(types.Length>=numItems, "[SerializationInfoEnumerator.ctor]types.Length>=numItems");
m_members = members;
m_data = info;
m_types = types;
//The MoveNext semantic is much easier if we enforce that [0..m_numItems] are valid entries
//in the enumerator, hence we subtract 1.
m_numItems = numItems-1;
m_currItem = -1;
m_current = false;
}
public bool MoveNext() {
if (m_currItem
Object IEnumerator.Current { //Actually returns a SerializationEntry
get {
if (m_current==false) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen"));
}
return (Object)(new SerializationEntry(m_members[m_currItem], m_data[m_currItem], m_types[m_currItem]));
}
}
public SerializationEntry Current { //Actually returns a SerializationEntry
get {
if (m_current==false) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen"));
}
return (new SerializationEntry(m_members[m_currItem], m_data[m_currItem], m_types[m_currItem]));
}
}
public void Reset() {
m_currItem = -1;
m_current = false;
}
public String Name {
get {
if (m_current==false) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen"));
}
return m_members[m_currItem];
}
}
public Object Value {
get {
if (m_current==false) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen"));
}
return m_data[m_currItem];
}
}
public Type ObjectType {
get {
if (m_current==false) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen"));
}
return m_types[m_currItem];
}
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OutputCacheProfileCollection.cs
- MouseCaptureWithinProperty.cs
- StrokeNodeOperations.cs
- ACL.cs
- FixedStringLookup.cs
- SignerInfo.cs
- XmlAttributeOverrides.cs
- Matrix.cs
- EdmProviderManifest.cs
- thaishape.cs
- DSASignatureFormatter.cs
- MissingManifestResourceException.cs
- SafeNativeMethods.cs
- DoubleAnimationClockResource.cs
- CommonDialog.cs
- ErrorLog.cs
- ArrayElementGridEntry.cs
- CapabilitiesPattern.cs
- RelatedView.cs
- XsltCompileContext.cs
- MarkupWriter.cs
- DefaultTextStore.cs
- DES.cs
- ViewStateModeByIdAttribute.cs
- ReferenceService.cs
- ImageFormat.cs
- ScriptingSectionGroup.cs
- PartialTrustVisibleAssemblyCollection.cs
- XmlSchemaSimpleType.cs
- QilTargetType.cs
- IndentedWriter.cs
- StorageComplexPropertyMapping.cs
- DynamicValueConverter.cs
- SerializationFieldInfo.cs
- IConvertible.cs
- Geometry3D.cs
- AppliedDeviceFiltersDialog.cs
- RoutedEventArgs.cs
- XPathCompiler.cs
- InstanceDataCollectionCollection.cs
- BitmapCache.cs
- DynamicFilterExpression.cs
- AstTree.cs
- ApplyImportsAction.cs
- Themes.cs
- HttpVersion.cs
- SvcMapFile.cs
- SizeConverter.cs
- PageThemeBuildProvider.cs
- SoapEnumAttribute.cs
- OrderedDictionaryStateHelper.cs
- UniqueIdentifierService.cs
- ColorBuilder.cs
- IdentityElement.cs
- DesignerAttributeInfo.cs
- PageTheme.cs
- DictionarySectionHandler.cs
- TemplateNodeContextMenu.cs
- DetailsViewDeleteEventArgs.cs
- IconHelper.cs
- IEnumerable.cs
- DomNameTable.cs
- CheckBoxAutomationPeer.cs
- Light.cs
- DuplicateMessageDetector.cs
- ReaderOutput.cs
- Propagator.Evaluator.cs
- DataGridViewCellCollection.cs
- DataIdProcessor.cs
- WebOperationContext.cs
- CapabilitiesRule.cs
- NullableLongMinMaxAggregationOperator.cs
- FtpRequestCacheValidator.cs
- versioninfo.cs
- BigInt.cs
- Math.cs
- tooltip.cs
- TextElementCollectionHelper.cs
- securestring.cs
- OutputWindow.cs
- ListContractAdapter.cs
- ElapsedEventArgs.cs
- NamespaceEmitter.cs
- ComboBox.cs
- FloaterParaClient.cs
- XmlDataSourceView.cs
- SiteMembershipCondition.cs
- DisableDpiAwarenessAttribute.cs
- BitmapCacheBrush.cs
- BaseValidator.cs
- TextRunProperties.cs
- CheckBoxField.cs
- ResourceDescriptionAttribute.cs
- CharEnumerator.cs
- RSAOAEPKeyExchangeDeformatter.cs
- DataGridRowAutomationPeer.cs
- TextDecoration.cs
- XamlGridLengthSerializer.cs
- MarkupExtensionParser.cs
- XmlNamespaceDeclarationsAttribute.cs