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
- TraceContextRecord.cs
- RedBlackList.cs
- _Events.cs
- JsonDeserializer.cs
- MemberPath.cs
- webclient.cs
- Dictionary.cs
- XmlFormatWriterGenerator.cs
- ZipPackagePart.cs
- PersonalizationProviderCollection.cs
- IfAction.cs
- AsyncOperation.cs
- XmlHierarchicalEnumerable.cs
- DataServiceHostFactory.cs
- Clause.cs
- XsltException.cs
- MembershipPasswordException.cs
- UnderstoodHeaders.cs
- CodeCastExpression.cs
- BuilderPropertyEntry.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- TextEffectResolver.cs
- GeneralTransform2DTo3DTo2D.cs
- SqlErrorCollection.cs
- Intellisense.cs
- cookieexception.cs
- MessageBodyMemberAttribute.cs
- MaskedTextProvider.cs
- DefaultShape.cs
- sqlpipe.cs
- FilterFactory.cs
- HyperLinkStyle.cs
- SafeFindHandle.cs
- AudioLevelUpdatedEventArgs.cs
- MouseActionValueSerializer.cs
- ListDictionaryInternal.cs
- CompiledIdentityConstraint.cs
- EmptyEnumerator.cs
- datacache.cs
- LinkLabel.cs
- XmlDocument.cs
- RepeaterItem.cs
- HtmlForm.cs
- VectorAnimationBase.cs
- ImageListImage.cs
- PropertyTab.cs
- BuildProvider.cs
- CompatibleIComparer.cs
- MimeObjectFactory.cs
- AsyncPostBackTrigger.cs
- XmlTextEncoder.cs
- BrushValueSerializer.cs
- DecoratedNameAttribute.cs
- InvalidOleVariantTypeException.cs
- PolygonHotSpot.cs
- SqlStatistics.cs
- StatusBarPanel.cs
- SqlUserDefinedAggregateAttribute.cs
- SymLanguageType.cs
- GetWorkflowTree.cs
- UserPreferenceChangingEventArgs.cs
- XmlResolver.cs
- EventHandlerList.cs
- BindingExpressionBase.cs
- MergeFilterQuery.cs
- HandlerMappingMemo.cs
- Invariant.cs
- PropertyItemInternal.cs
- FilePrompt.cs
- UndoEngine.cs
- ExtentKey.cs
- Soap.cs
- ArithmeticException.cs
- InterleavedZipPartStream.cs
- ChannelProtectionRequirements.cs
- WindowsRegion.cs
- TreeViewItem.cs
- Int32Animation.cs
- UIElement.cs
- SerializerProvider.cs
- entityreference_tresulttype.cs
- XmlWriterSettings.cs
- SqlFacetAttribute.cs
- BaseCodeDomTreeGenerator.cs
- RewritingValidator.cs
- WorkflowEventArgs.cs
- PolicyLevel.cs
- FileUpload.cs
- ContainerParagraph.cs
- StringComparer.cs
- DefaultMergeHelper.cs
- OutputCache.cs
- DataGridViewTopLeftHeaderCell.cs
- UnsafeNativeMethods.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- UrlPath.cs
- Message.cs
- TagPrefixCollection.cs
- Mappings.cs
- OciLobLocator.cs