Code:
/ 4.0 / 4.0 / untmp / 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
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MarkupCompiler.cs
- DetailsViewPagerRow.cs
- TimelineCollection.cs
- Itemizer.cs
- XmlParser.cs
- CompositeCollectionView.cs
- BmpBitmapEncoder.cs
- RC2CryptoServiceProvider.cs
- TraceSwitch.cs
- _LocalDataStoreMgr.cs
- QilBinary.cs
- VectorValueSerializer.cs
- StackBuilderSink.cs
- TextCharacters.cs
- MsmqEncryptionAlgorithm.cs
- CalendarDateChangedEventArgs.cs
- DBDataPermissionAttribute.cs
- SoapObjectReader.cs
- ObjectDataSourceDisposingEventArgs.cs
- DataColumnMappingCollection.cs
- ValueUtilsSmi.cs
- TerminatorSinks.cs
- HttpRuntimeSection.cs
- BasicCommandTreeVisitor.cs
- StringBuilder.cs
- KeyFrames.cs
- SecurityHeaderLayout.cs
- TCPListener.cs
- XmlSchemaComplexContent.cs
- DynamicEntity.cs
- DictionaryEntry.cs
- XmlHelper.cs
- EntityContainerAssociationSet.cs
- XPathDocumentNavigator.cs
- DesignBindingPropertyDescriptor.cs
- SQLDouble.cs
- Substitution.cs
- CollectionChange.cs
- AdRotator.cs
- SoapInteropTypes.cs
- XsltSettings.cs
- AccessText.cs
- TextLineBreak.cs
- ResourceDisplayNameAttribute.cs
- GC.cs
- ScaleTransform.cs
- DPTypeDescriptorContext.cs
- NameTable.cs
- PropertyValueChangedEvent.cs
- StandardOleMarshalObject.cs
- StatusBarDrawItemEvent.cs
- ByteAnimationBase.cs
- Unit.cs
- RectKeyFrameCollection.cs
- GridViewUpdateEventArgs.cs
- ReachDocumentReferenceCollectionSerializer.cs
- IndexedWhereQueryOperator.cs
- FieldNameLookup.cs
- EntityDataSourceConfigureObjectContext.cs
- ServiceModelSecurityTokenTypes.cs
- DataObjectEventArgs.cs
- CorrelationToken.cs
- Geometry3D.cs
- SchemaMerger.cs
- Bookmark.cs
- ObjectResult.cs
- RequiredFieldValidator.cs
- EntityConnectionStringBuilderItem.cs
- SHA256Managed.cs
- _LocalDataStoreMgr.cs
- DataFieldConverter.cs
- PageTheme.cs
- SymbolDocumentInfo.cs
- WorkflowHostingEndpoint.cs
- dbenumerator.cs
- XmlBufferedByteStreamReader.cs
- Attributes.cs
- ObjectViewQueryResultData.cs
- DetailsViewCommandEventArgs.cs
- OracleParameterCollection.cs
- MappingModelBuildProvider.cs
- MultidimensionalArrayItemReference.cs
- CalendarDay.cs
- SingleAnimationUsingKeyFrames.cs
- MetadataSource.cs
- EdmFunctions.cs
- WsatServiceAddress.cs
- HttpHeaderCollection.cs
- AnimationStorage.cs
- documentsequencetextview.cs
- BasicViewGenerator.cs
- HttpDictionary.cs
- IdleTimeoutMonitor.cs
- _NegoState.cs
- PartManifestEntry.cs
- FieldToken.cs
- WebControlsSection.cs
- DataBoundControlAdapter.cs
- CustomAttributeSerializer.cs
- ContractSearchPattern.cs