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
- HostingPreferredMapPath.cs
- CharAnimationBase.cs
- CustomError.cs
- Underline.cs
- FlowDocumentView.cs
- StringUtil.cs
- TabItem.cs
- ScriptControl.cs
- RichTextBox.cs
- CachedFontFamily.cs
- DateBoldEvent.cs
- UserControl.cs
- ControlDesigner.cs
- DataControlImageButton.cs
- DynamicDiscoSearcher.cs
- SendSecurityHeaderElementContainer.cs
- Package.cs
- BufferAllocator.cs
- MatrixAnimationBase.cs
- DataGridBoolColumn.cs
- SR.cs
- DrawingAttributesDefaultValueFactory.cs
- LZCodec.cs
- SQLInt32Storage.cs
- MarkupCompilePass2.cs
- ResetableIterator.cs
- JsonDataContract.cs
- ClientSideQueueItem.cs
- DataSourceUtil.cs
- GeometryHitTestResult.cs
- SchemaCollectionCompiler.cs
- WorkflowTimerService.cs
- TextEditorSpelling.cs
- ReachFixedDocumentSerializerAsync.cs
- SqlTransaction.cs
- PrivilegeNotHeldException.cs
- IdentitySection.cs
- SharedDp.cs
- PartBasedPackageProperties.cs
- ZipPackagePart.cs
- AtomServiceDocumentSerializer.cs
- DependencyPropertyKind.cs
- OdbcEnvironment.cs
- CornerRadius.cs
- WindowInteropHelper.cs
- PagesChangedEventArgs.cs
- MenuAutomationPeer.cs
- TypeInitializationException.cs
- TraceContextEventArgs.cs
- NullableLongAverageAggregationOperator.cs
- EraserBehavior.cs
- GridViewPageEventArgs.cs
- UpdateTranslator.cs
- PointLight.cs
- EnumConverter.cs
- CopyOnWriteList.cs
- VersionedStreamOwner.cs
- InternalConfigRoot.cs
- SiteMapNodeCollection.cs
- RuleAttributes.cs
- DataGridBoolColumn.cs
- TextOptionsInternal.cs
- StringUtil.cs
- LazyTextWriterCreator.cs
- HtmlTable.cs
- CancelEventArgs.cs
- VerticalAlignConverter.cs
- EntityDataSourceSelectedEventArgs.cs
- IndexedString.cs
- SafeNativeMethodsMilCoreApi.cs
- ItemList.cs
- NumericPagerField.cs
- DateTimePicker.cs
- AutomationPatternInfo.cs
- DecoderBestFitFallback.cs
- AutomationEventArgs.cs
- CalculatedColumn.cs
- XmlDocument.cs
- SqlUtils.cs
- PropagatorResult.cs
- HttpApplicationFactory.cs
- ALinqExpressionVisitor.cs
- HtmlInputButton.cs
- OpCodes.cs
- PropertyMapper.cs
- FormsAuthenticationUser.cs
- RegionIterator.cs
- UrlAuthorizationModule.cs
- DeriveBytes.cs
- basevalidator.cs
- DesignBindingPicker.cs
- AddInAdapter.cs
- ExternalDataExchangeService.cs
- VectorAnimationBase.cs
- SeekStoryboard.cs
- AppDomainManager.cs
- ToolboxBitmapAttribute.cs
- XsltOutput.cs
- PublishLicense.cs
- _NegoStream.cs