Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Runtime / Serialization / SerializationInfoEnumerator.cs / 1305376 / 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; using System.Diagnostics.Contracts; // // 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) { Contract.Assert(members!=null, "[SerializationInfoEnumerator.ctor]members!=null"); Contract.Assert(info!=null, "[SerializationInfoEnumerator.ctor]info!=null"); Contract.Assert(types!=null, "[SerializationInfoEnumerator.ctor]types!=null"); Contract.Assert(numItems>=0, "[SerializationInfoEnumerator.ctor]numItems>=0"); Contract.Assert(members.Length>=numItems, "[SerializationInfoEnumerator.ctor]members.Length>=numItems"); Contract.Assert(info.Length>=numItems, "[SerializationInfoEnumerator.ctor]info.Length>=numItems"); Contract.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_currItemObject 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]; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // 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; using System.Diagnostics.Contracts; // // 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) { Contract.Assert(members!=null, "[SerializationInfoEnumerator.ctor]members!=null"); Contract.Assert(info!=null, "[SerializationInfoEnumerator.ctor]info!=null"); Contract.Assert(types!=null, "[SerializationInfoEnumerator.ctor]types!=null"); Contract.Assert(numItems>=0, "[SerializationInfoEnumerator.ctor]numItems>=0"); Contract.Assert(members.Length>=numItems, "[SerializationInfoEnumerator.ctor]members.Length>=numItems"); Contract.Assert(info.Length>=numItems, "[SerializationInfoEnumerator.ctor]info.Length>=numItems"); Contract.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]; } } } } // 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
- NetStream.cs
- XamlFigureLengthSerializer.cs
- ImportContext.cs
- Transform.cs
- HostingEnvironmentSection.cs
- ModuleBuilderData.cs
- PropertyReferenceSerializer.cs
- SessionState.cs
- RelationshipSet.cs
- EventBuilder.cs
- PartEditor.cs
- SnapLine.cs
- ReservationNotFoundException.cs
- CustomWebEventKey.cs
- DataGridViewCellLinkedList.cs
- PenContexts.cs
- SafeRightsManagementSessionHandle.cs
- TabItemAutomationPeer.cs
- SqlLiftWhereClauses.cs
- mongolianshape.cs
- DivideByZeroException.cs
- MediaSystem.cs
- XmlNodeComparer.cs
- SchemaElementLookUpTable.cs
- ConfigurationManagerInternalFactory.cs
- XmlCountingReader.cs
- CursorConverter.cs
- Int64Converter.cs
- SingleStorage.cs
- DataGridViewComboBoxColumn.cs
- SetStateEventArgs.cs
- CheckStoreFileValidityRequest.cs
- ResourceKey.cs
- QilStrConcat.cs
- MultipleFilterMatchesException.cs
- DataBindEngine.cs
- LockCookie.cs
- TreeNodeStyleCollection.cs
- XmlException.cs
- WorkflowTransactionService.cs
- RenderDataDrawingContext.cs
- SettingsPropertyValue.cs
- IPAddress.cs
- DBPropSet.cs
- ThreadExceptionDialog.cs
- Invariant.cs
- ZipFileInfo.cs
- Tracer.cs
- TripleDESCryptoServiceProvider.cs
- BitmapCodecInfoInternal.cs
- DesignerCalendarAdapter.cs
- ControlValuePropertyAttribute.cs
- CaseInsensitiveHashCodeProvider.cs
- StubHelpers.cs
- SqlLiftWhereClauses.cs
- StylusEventArgs.cs
- Int32RectValueSerializer.cs
- SafeHandles.cs
- CellConstantDomain.cs
- FixUpCollection.cs
- PenContext.cs
- Int16Storage.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- WebServiceHost.cs
- xmlformatgeneratorstatics.cs
- SpellerStatusTable.cs
- XamlInterfaces.cs
- DuplexSecurityProtocolFactory.cs
- COM2PropertyBuilderUITypeEditor.cs
- AuthenticationService.cs
- Helpers.cs
- _AutoWebProxyScriptHelper.cs
- ActivityStatusChangeEventArgs.cs
- MailHeaderInfo.cs
- MissingMethodException.cs
- TdsValueSetter.cs
- GenericFlowSwitchHelper.cs
- TypedServiceOperationListItem.cs
- IPPacketInformation.cs
- PostBackOptions.cs
- MDIControlStrip.cs
- UserThread.cs
- KernelTypeValidation.cs
- ChtmlImageAdapter.cs
- ContextDataSource.cs
- ValueChangedEventManager.cs
- OutputCacheProfileCollection.cs
- CapabilitiesUse.cs
- WebPartTransformerAttribute.cs
- Base64Encoder.cs
- SwitchExpression.cs
- SoapInteropTypes.cs
- HierarchicalDataBoundControlAdapter.cs
- RTLAwareMessageBox.cs
- MSG.cs
- IgnoreSection.cs
- Activator.cs
- FieldToken.cs
- CodeMemberMethod.cs
- InternalControlCollection.cs