Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Runtime / Serialization / Formatters / Binary / BinaryObjectInfo.cs / 1305376 / BinaryObjectInfo.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: SerObjectInfo ** ** ** Purpose: Holds information about an objects Members ** ** ===========================================================*/ namespace System.Runtime.Serialization.Formatters.Binary { using System.Runtime.Remoting; using System.Runtime.Serialization; using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Diagnostics; using System.Globalization; using System.Diagnostics.Contracts; // This class contains information about an object. It is used so that // the rest of the Formatter routines can use a common interface for // a normal object, an ISerializable object, and a surrogate object // // The methods in this class are for the internal use of the Formatters. // There use will be restricted when signing is supported for assemblies internal sealed class WriteObjectInfo { internal int objectInfoId; internal Object obj; internal Type objectType; internal bool isSi = false; internal bool isNamed = false; // disable csharp compiler warning #0414: field assigned unused value #pragma warning disable 0414 internal bool isTyped = false; #pragma warning restore 0414 internal bool isArray = false; internal SerializationInfo si = null; internal SerObjectInfoCache cache = null; internal Object[] memberData = null; internal ISerializationSurrogate serializationSurrogate = null; internal StreamingContext context; internal SerObjectInfoInit serObjectInfoInit = null; // Writing and Parsing information internal long objectId; internal long assemId; // Binder information string binderTypeName; string binderAssemblyString; internal WriteObjectInfo() { } internal void ObjectEnd() { SerTrace.Log( this, objectInfoId," objectType ",objectType," ObjectEnd"); PutObjectInfo(serObjectInfoInit, this); } private void InternalInit() { SerTrace.Log( this, objectInfoId," objectType ",objectType," InternalInit"); obj = null; objectType = null; isSi = false; isNamed = false; isTyped = false; isArray = false; si = null; cache = null; memberData = null; // Writing and Parsing information objectId = 0; assemId = 0; // Binder information binderTypeName = null; binderAssemblyString = null; } [System.Security.SecurityCritical] // auto-generated internal static WriteObjectInfo Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) { WriteObjectInfo soi = GetObjectInfo(serObjectInfoInit); soi.InitSerialize(obj, surrogateSelector, context, serObjectInfoInit, converter, objectWriter, binder); return soi; } // Write constructor [System.Security.SecurityCritical] // auto-generated internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) { SerTrace.Log( this, objectInfoId," Constructor 1 ",obj); this.context = context; this.obj = obj; this.serObjectInfoInit = serObjectInfoInit; ISurrogateSelector surrogateSelectorTemp; #if FEATURE_REMOTING if (RemotingServices.IsTransparentProxy(obj)) objectType = Converter.typeofMarshalByRefObject; else #endif objectType = obj.GetType(); if (objectType.IsArray) { isArray = true; InitNoMembers(); return; } InvokeSerializationBinder(binder); SerTrace.Log( this, objectInfoId," Constructor 1 trace 2"); objectWriter.ObjectManager.RegisterObject(obj); if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null) { SerTrace.Log( this, objectInfoId," Constructor 1 trace 3"); si = new SerializationInfo(objectType, converter); if (!objectType.IsPrimitive) serializationSurrogate.GetObjectData(obj, si, context); InitSiWrite(); } else if (obj is ISerializable) { if (!objectType.IsSerializable) { throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", objectType.FullName, objectType.Assembly.FullName)); } si = new SerializationInfo(objectType, converter); #if FEATURE_SERIALIZATION ((ISerializable)obj).GetObjectData(si, context); #endif SerTrace.Log( this, objectInfoId," Constructor 1 trace 4 ISerializable "+objectType); InitSiWrite(); } else { SerTrace.Log(this, objectInfoId," Constructor 1 trace 5"); InitMemberInfo(); } } [Conditional("SER_LOGGING")] private void DumpMemberInfo() { for (int i=0; imemberTypesList; internal SerObjectInfoInit serObjectInfoInit = null; internal IFormatterConverter formatterConverter; internal ReadObjectInfo() { } internal void ObjectEnd() { SerTrace.Log( this, objectInfoId," objectType ",objectType," ObjectEnd"); } internal void PrepareForReuse() { lastPosition = 0; } [System.Security.SecurityCritical] // auto-generated internal static ReadObjectInfo Create(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { ReadObjectInfo soi = GetObjectInfo(serObjectInfoInit); soi.Init(objectType, surrogateSelector, context, objectManager, serObjectInfoInit, converter, bSimpleAssembly); return soi; } // Read Constructor [System.Security.SecurityCritical] // auto-generated internal void Init(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { SerTrace.Log( this, objectInfoId," Constructor 3 ",objectType); this.objectType = objectType; this.objectManager = objectManager; this.context = context; this.serObjectInfoInit = serObjectInfoInit; this.formatterConverter = converter; this.bSimpleAssembly = bSimpleAssembly; InitReadConstructor(objectType, surrogateSelector, context); } [System.Security.SecurityCritical] // auto-generated internal static ReadObjectInfo Create(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { ReadObjectInfo soi = GetObjectInfo(serObjectInfoInit); soi.Init(objectType, memberNames,memberTypes, surrogateSelector, context, objectManager, serObjectInfoInit, converter, bSimpleAssembly); return soi; } // Read Constructor [System.Security.SecurityCritical] // auto-generated internal void Init(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { SerTrace.Log( this,objectInfoId, " Constructor 5 ",objectType); this.objectType = objectType; this.objectManager = objectManager; this.wireMemberNames = memberNames; this.wireMemberTypes = memberTypes; this.context = context; this.serObjectInfoInit = serObjectInfoInit; this.formatterConverter = converter; this.bSimpleAssembly = bSimpleAssembly; if (memberNames != null) isNamed = true; if (memberTypes != null) isTyped = true; if ((object)objectType != null) InitReadConstructor(objectType, surrogateSelector, context); } [System.Security.SecurityCritical] // auto-generated private void InitReadConstructor(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context) { SerTrace.Log( this,objectInfoId," ", objectType," InitReadConstructor Entry ",objectType); if (objectType.IsArray) { InitNoMembers(); return; } ISurrogateSelector surrogateSelectorTemp = null; if (surrogateSelector!=null) serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp); if (serializationSurrogate != null) { isSi = true; } else if (Object.ReferenceEquals(objectType, Converter.typeofObject)) { } else if (Converter.typeofISerializable.IsAssignableFrom(objectType)) isSi = true; if (isSi) { InitSiRead(); } else { InitMemberInfo(); } SerTrace.Log( this,objectInfoId," ", objectType," InitReadConstructor Exit ",isSi); } private void InitSiRead() { if (memberTypesList != null) { memberTypesList = new List (20); } } private void InitNoMembers() { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(objectType); } [System.Security.SecurityCritical] // auto-generated private void InitMemberInfo() { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo Entry"); SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(objectType); cache.memberInfos = FormatterServices.GetSerializableMembers(objectType, context); count = cache.memberInfos.Length; cache.memberNames = new String[count]; cache.memberTypes = new Type[count]; // Calculate new arrays for (int i=0; i 0 && cache.memberNames[lastPosition].Equals(name)) { return lastPosition; } else if ((++lastPosition < cache.memberNames.Length) && (cache.memberNames[lastPosition].Equals(name))) { return lastPosition; } else { // Search for name SerTrace.Log( this, objectInfoId," Position miss search for name "+name); for (int i=0; i memberTypesList; internal SerObjectInfoInit serObjectInfoInit = null; internal IFormatterConverter formatterConverter; internal ReadObjectInfo() { } internal void ObjectEnd() { SerTrace.Log( this, objectInfoId," objectType ",objectType," ObjectEnd"); } internal void PrepareForReuse() { lastPosition = 0; } [System.Security.SecurityCritical] // auto-generated internal static ReadObjectInfo Create(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { ReadObjectInfo soi = GetObjectInfo(serObjectInfoInit); soi.Init(objectType, surrogateSelector, context, objectManager, serObjectInfoInit, converter, bSimpleAssembly); return soi; } // Read Constructor [System.Security.SecurityCritical] // auto-generated internal void Init(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { SerTrace.Log( this, objectInfoId," Constructor 3 ",objectType); this.objectType = objectType; this.objectManager = objectManager; this.context = context; this.serObjectInfoInit = serObjectInfoInit; this.formatterConverter = converter; this.bSimpleAssembly = bSimpleAssembly; InitReadConstructor(objectType, surrogateSelector, context); } [System.Security.SecurityCritical] // auto-generated internal static ReadObjectInfo Create(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { ReadObjectInfo soi = GetObjectInfo(serObjectInfoInit); soi.Init(objectType, memberNames,memberTypes, surrogateSelector, context, objectManager, serObjectInfoInit, converter, bSimpleAssembly); return soi; } // Read Constructor [System.Security.SecurityCritical] // auto-generated internal void Init(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, bool bSimpleAssembly) { SerTrace.Log( this,objectInfoId, " Constructor 5 ",objectType); this.objectType = objectType; this.objectManager = objectManager; this.wireMemberNames = memberNames; this.wireMemberTypes = memberTypes; this.context = context; this.serObjectInfoInit = serObjectInfoInit; this.formatterConverter = converter; this.bSimpleAssembly = bSimpleAssembly; if (memberNames != null) isNamed = true; if (memberTypes != null) isTyped = true; if ((object)objectType != null) InitReadConstructor(objectType, surrogateSelector, context); } [System.Security.SecurityCritical] // auto-generated private void InitReadConstructor(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context) { SerTrace.Log( this,objectInfoId," ", objectType," InitReadConstructor Entry ",objectType); if (objectType.IsArray) { InitNoMembers(); return; } ISurrogateSelector surrogateSelectorTemp = null; if (surrogateSelector!=null) serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp); if (serializationSurrogate != null) { isSi = true; } else if (Object.ReferenceEquals(objectType, Converter.typeofObject)) { } else if (Converter.typeofISerializable.IsAssignableFrom(objectType)) isSi = true; if (isSi) { InitSiRead(); } else { InitMemberInfo(); } SerTrace.Log( this,objectInfoId," ", objectType," InitReadConstructor Exit ",isSi); } private void InitSiRead() { if (memberTypesList != null) { memberTypesList = new List (20); } } private void InitNoMembers() { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(objectType); } [System.Security.SecurityCritical] // auto-generated private void InitMemberInfo() { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo Entry"); SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(objectType); cache.memberInfos = FormatterServices.GetSerializableMembers(objectType, context); count = cache.memberInfos.Length; cache.memberNames = new String[count]; cache.memberTypes = new Type[count]; // Calculate new arrays for (int i=0; i 0 && cache.memberNames[lastPosition].Equals(name)) { return lastPosition; } else if ((++lastPosition < cache.memberNames.Length) && (cache.memberNames[lastPosition].Equals(name))) { return lastPosition; } else { // Search for name SerTrace.Log( this, objectInfoId," Position miss search for name "+name); for (int i=0; i
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MouseBinding.cs
- userdatakeys.cs
- EventRecordWrittenEventArgs.cs
- MimeXmlReflector.cs
- SwitchAttribute.cs
- CharacterHit.cs
- HostedElements.cs
- WebControlsSection.cs
- SoundPlayer.cs
- ExpanderAutomationPeer.cs
- Statements.cs
- Translator.cs
- TemplateControlBuildProvider.cs
- TimeoutException.cs
- RoleGroup.cs
- ADMembershipUser.cs
- ImageKeyConverter.cs
- FixedPageStructure.cs
- WindowsSolidBrush.cs
- EncodingStreamWrapper.cs
- ServiceHttpHandlerFactory.cs
- RegexCaptureCollection.cs
- EventLogPermissionEntry.cs
- SelectedGridItemChangedEvent.cs
- IERequestCache.cs
- DataObjectMethodAttribute.cs
- OdbcConnectionString.cs
- NonParentingControl.cs
- EntitySqlQueryCacheKey.cs
- InfoCardHelper.cs
- HtmlInputCheckBox.cs
- OciLobLocator.cs
- DependencyPropertyAttribute.cs
- VisualTreeUtils.cs
- HtmlLabelAdapter.cs
- BuildManagerHost.cs
- BStrWrapper.cs
- WindowsPen.cs
- Regex.cs
- Message.cs
- ImportContext.cs
- ToolTip.cs
- IdentityNotMappedException.cs
- CopyCodeAction.cs
- SimpleType.cs
- FixedSOMTextRun.cs
- FixedDocumentPaginator.cs
- DataSourceCacheDurationConverter.cs
- SQlBooleanStorage.cs
- CompModSwitches.cs
- HwndMouseInputProvider.cs
- ItemContainerPattern.cs
- InputManager.cs
- StrokeIntersection.cs
- InheritedPropertyChangedEventArgs.cs
- KeyValuePair.cs
- LoginName.cs
- ConfigurationValidatorBase.cs
- TokenBasedSetEnumerator.cs
- Stack.cs
- StringValidatorAttribute.cs
- ChineseLunisolarCalendar.cs
- LoginView.cs
- MemberRestriction.cs
- BuildManagerHost.cs
- SelectingProviderEventArgs.cs
- SerializationStore.cs
- UriSectionData.cs
- BooleanAnimationUsingKeyFrames.cs
- Enum.cs
- DesignerSerializationOptionsAttribute.cs
- TransportConfigurationTypeElementCollection.cs
- BitmapEffectInput.cs
- SelectionItemProviderWrapper.cs
- ObjectViewFactory.cs
- ObjectResult.cs
- TabControlAutomationPeer.cs
- TreeNodeCollection.cs
- WindowsGraphicsWrapper.cs
- WindowsAltTab.cs
- Serializer.cs
- ColumnProvider.cs
- PageHandlerFactory.cs
- TypeBuilderInstantiation.cs
- XmlSchemaValidator.cs
- JournalEntryStack.cs
- Soap12ProtocolImporter.cs
- RegularExpressionValidator.cs
- TextRangeSerialization.cs
- ExecutorLocksHeldException.cs
- TreeNodeStyle.cs
- KeyConverter.cs
- SQLDouble.cs
- DataGridColumnsPage.cs
- GradientStop.cs
- ToolStripDropTargetManager.cs
- glyphs.cs
- VideoDrawing.cs
- DBCSCodePageEncoding.cs
- HtmlTableCell.cs