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
- StylusPointDescription.cs
- DataGridViewSelectedRowCollection.cs
- WindowsGraphics2.cs
- MD5.cs
- UpdateCompiler.cs
- QueryInterceptorAttribute.cs
- PersonalizablePropertyEntry.cs
- ActivationServices.cs
- WorkflowServiceNamespace.cs
- OracleException.cs
- PriorityBinding.cs
- EventHandlingScope.cs
- TypeDelegator.cs
- ButtonChrome.cs
- DynamicValueConverter.cs
- Variant.cs
- CompositeActivityValidator.cs
- FlowDocumentReaderAutomationPeer.cs
- MarkupExtensionSerializer.cs
- rsa.cs
- AuthenticatingEventArgs.cs
- StylusLogic.cs
- DataControlImageButton.cs
- DoubleAnimation.cs
- LineUtil.cs
- LockingPersistenceProvider.cs
- XmlSchemaType.cs
- ParameterExpression.cs
- StorageRoot.cs
- AppDomainProtocolHandler.cs
- PassportPrincipal.cs
- IntegerValidator.cs
- HttpRuntime.cs
- PixelFormatConverter.cs
- PostBackTrigger.cs
- DesignerExtenders.cs
- InProcStateClientManager.cs
- XmlSecureResolver.cs
- StrokeNodeEnumerator.cs
- OutgoingWebResponseContext.cs
- CodeDomConfigurationHandler.cs
- ComponentChangedEvent.cs
- VariableQuery.cs
- Line.cs
- EdmSchemaError.cs
- Container.cs
- QuaternionKeyFrameCollection.cs
- MemberPath.cs
- HitTestWithGeometryDrawingContextWalker.cs
- MostlySingletonList.cs
- Repeater.cs
- BindingExpressionUncommonField.cs
- ISessionStateStore.cs
- DefaultValueConverter.cs
- BulletedListEventArgs.cs
- DataContractJsonSerializer.cs
- DataGridColumn.cs
- BufferedGraphicsContext.cs
- StateFinalizationDesigner.cs
- Translator.cs
- ViewService.cs
- _ProxyChain.cs
- FamilyCollection.cs
- ScriptControl.cs
- Util.cs
- DataGridCell.cs
- safePerfProviderHandle.cs
- RegistryKey.cs
- DesignerDataTableBase.cs
- SoapObjectReader.cs
- TimeSpanMinutesConverter.cs
- PaintValueEventArgs.cs
- CheckBoxField.cs
- XomlCompilerError.cs
- GlyphTypeface.cs
- XmlElementList.cs
- HwndHost.cs
- MemoryPressure.cs
- InfiniteTimeSpanConverter.cs
- ToolboxItemCollection.cs
- SafeCertificateContext.cs
- ListViewGroup.cs
- BackgroundFormatInfo.cs
- SimpleBitVector32.cs
- XPathNavigatorReader.cs
- IisTraceWebEventProvider.cs
- GridViewUpdatedEventArgs.cs
- SiteMapDataSourceDesigner.cs
- WindowsButton.cs
- ExtenderControl.cs
- PersonalizationProviderHelper.cs
- PriorityBinding.cs
- Stack.cs
- ListenerElementsCollection.cs
- SettingsAttributeDictionary.cs
- TailCallAnalyzer.cs
- Base64Decoder.cs
- HandleCollector.cs
- SecurityToken.cs
- FixedSOMPageConstructor.cs