Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / System / Runtime / Serialization / Formatters / Binary / BinaryObjectInfo.cs / 1 / 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.Reflection;
using System.Diagnostics;
using System.Globalization;
// 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;
internal bool isTyped = false;
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;
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;
}
internal static WriteObjectInfo Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
{
WriteObjectInfo soi = GetObjectInfo(serObjectInfoInit);
soi.InitSerialize(obj, surrogateSelector, context, serObjectInfoInit, converter, objectWriter);
return soi;
}
// Write constructor
internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
{
SerTrace.Log( this, objectInfoId," Constructor 1 ",obj);
this.context = context;
this.obj = obj;
this.serObjectInfoInit = serObjectInfoInit;
ISurrogateSelector surrogateSelectorTemp;
if (RemotingServices.IsTransparentProxy(obj))
objectType = Converter.typeofMarshalByRefObject;
else
objectType = obj.GetType();
if (objectType.IsArray)
{
isArray = true;
InitNoMembers();
return;
}
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(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Serialization_NonSerType"),
objectType.FullName, objectType.Assembly.FullName));
}
si = new SerializationInfo(objectType, converter);
((ISerializable)obj).GetObjectData(si, context);
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; i0 && 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; i0 && 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
- DateTimeAutomationPeer.cs
- Point3DIndependentAnimationStorage.cs
- Event.cs
- WebCategoryAttribute.cs
- WindowAutomationPeer.cs
- MultipartContentParser.cs
- BitHelper.cs
- DefaultPrintController.cs
- SafeThreadHandle.cs
- Run.cs
- Merger.cs
- LocationUpdates.cs
- KeyTime.cs
- unsafenativemethodstextservices.cs
- DataServiceException.cs
- TransactionScope.cs
- AddInController.cs
- IPGlobalProperties.cs
- OletxResourceManager.cs
- WindowsTab.cs
- SerializationSectionGroup.cs
- SQLResource.cs
- WebServiceTypeData.cs
- ServerValidateEventArgs.cs
- _SingleItemRequestCache.cs
- GridViewCancelEditEventArgs.cs
- Message.cs
- XmlObjectSerializerWriteContext.cs
- TextProperties.cs
- TextElement.cs
- SQLInt32Storage.cs
- SqlVisitor.cs
- CriticalExceptions.cs
- ConfigurationStrings.cs
- MsdtcClusterUtils.cs
- PropertyChangingEventArgs.cs
- PassportPrincipal.cs
- WebPartVerbsEventArgs.cs
- Int32Storage.cs
- RijndaelManaged.cs
- DataObjectFieldAttribute.cs
- DoubleAnimationBase.cs
- Filter.cs
- EnterpriseServicesHelper.cs
- IntSumAggregationOperator.cs
- CustomBindingCollectionElement.cs
- QueryException.cs
- LockedAssemblyCache.cs
- ValidationHelpers.cs
- SmtpException.cs
- EmbeddedMailObjectsCollection.cs
- XmlSerializer.cs
- SQLInt32.cs
- Activity.cs
- NopReturnReader.cs
- SubpageParaClient.cs
- TargetControlTypeCache.cs
- EmptyImpersonationContext.cs
- SpeechUI.cs
- XomlCompilerResults.cs
- XslAst.cs
- AttachedPropertiesService.cs
- SqlException.cs
- DistinctQueryOperator.cs
- LockedBorderGlyph.cs
- SqlOuterApplyReducer.cs
- LinkLabelLinkClickedEvent.cs
- ObjectQueryExecutionPlan.cs
- SchemaTypeEmitter.cs
- PropertyToken.cs
- ExtensionSimplifierMarkupObject.cs
- BitmapDecoder.cs
- SqlParameter.cs
- TransformedBitmap.cs
- NonBatchDirectoryCompiler.cs
- VectorCollectionValueSerializer.cs
- RotateTransform.cs
- ThaiBuddhistCalendar.cs
- ConfigXmlText.cs
- SynchronizationContext.cs
- CustomAttributeFormatException.cs
- EncryptedKey.cs
- ErrorWebPart.cs
- FixedLineResult.cs
- BridgeDataReader.cs
- InertiaRotationBehavior.cs
- LiteralLink.cs
- TransportContext.cs
- QuaternionAnimation.cs
- ToolStripScrollButton.cs
- LoginName.cs
- CodeTypeDelegate.cs
- OracleInfoMessageEventArgs.cs
- DrawingContext.cs
- Localizer.cs
- XmlSchemaGroup.cs
- Site.cs
- RawStylusInputReport.cs
- CompressStream.cs
- LinkTarget.cs