private void InitMemberInfo() { if (!_serObjectInfoInit._seenBeforeTable.TryGetValue(_objectType, out _cache)) { _cache = new SerObjectInfoCache(_objectType); _cache._memberInfos = FormatterServices.GetSerializableMembers(_objectType, _context); int count = _cache._memberInfos.Length; _cache._memberNames = new string[count]; _cache._memberTypes = new Type[count]; // Calculate new arrays for (int i = 0; i < count; i++) { _cache._memberNames[i] = _cache._memberInfos[i].Name; _cache._memberTypes[i] = ((FieldInfo)_cache._memberInfos[i]).FieldType; } _serObjectInfoInit._seenBeforeTable.Add(_objectType, _cache); } if (_obj != null) { _memberData = FormatterServices.GetObjectData(_obj, _cache._memberInfos); } _isNamed = true; }
private void InitNoMembers() { SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo new cache"); cache = new SerObjectInfoCache(); cache.fullTypeName = objectType.FullName; cache.assemblyString = objectType.Module.Assembly.FullName; }
private void InitMemberInfo() { SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo Entry"); SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo new cache"); cache = new SerObjectInfoCache(); 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 < count; i++) { cache.memberNames[i] = cache.memberInfos[i].Name; cache.memberTypes[i] = GetMemberType(cache.memberInfos[i]); SerTrace.Log(this, objectInfoId, " InitMemberInfo name ", cache.memberNames[i], ", type ", cache.memberTypes[i], ", memberInfoType ", cache.memberInfos[i].GetType()); } cache.fullTypeName = objectType.FullName; cache.assemblyString = objectType.Module.Assembly.FullName; isTyped = true; isNamed = true; SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo Exit"); }
private void InitNoMembers() { if (!_serObjectInfoInit._seenBeforeTable.TryGetValue(_objectType, out _cache)) { _cache = new SerObjectInfoCache(_objectType); _serObjectInfoInit._seenBeforeTable.Add(_objectType, _cache); } }
private void InitSiWrite() { SerTrace.Log(this, objectInfoId, " InitSiWrite Entry "); SerializationInfoEnumerator siEnum = null; isSi = true; siEnum = si.GetEnumerator(); int infoLength = 0; infoLength = si.MemberCount; int count = infoLength; // For ISerializable cache cannot be saved because each object instance can have different values // BinaryWriter only puts the map on the wire if the ISerializable map cannot be reused. TypeInformation typeInformation = null; string fullTypeName = si.FullTypeName; string assemblyString = si.AssemblyName; bool hasTypeForwardedFrom = false; if (!si.IsFullTypeNameSetExplicit) { typeInformation = BinaryFormatter.GetTypeInformation(si.ObjectType); fullTypeName = typeInformation.FullTypeName; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } if (!si.IsAssemblyNameSetExplicit) { if (typeInformation == null) { typeInformation = BinaryFormatter.GetTypeInformation(si.ObjectType); } assemblyString = typeInformation.AssemblyString; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } cache = new SerObjectInfoCache(fullTypeName, assemblyString, hasTypeForwardedFrom); cache.memberNames = new String[count]; cache.memberTypes = new Type[count]; memberData = new Object[count]; siEnum = si.GetEnumerator(); for (int i = 0; siEnum.MoveNext(); i++) { cache.memberNames[i] = siEnum.Name; cache.memberTypes[i] = siEnum.ObjectType; memberData[i] = siEnum.Value; SerTrace.Log(this, objectInfoId + " ", objectType, " InitSiWrite ", cache.memberNames[i], " Type ", cache.memberTypes[i], " data ", memberData[i]); } isNamed = true; isTyped = false; SerTrace.Log(this, objectInfoId, " InitSiWrite Exit "); }
private void InitNoMembers() { this.cache = (SerObjectInfoCache)this.serObjectInfoInit.seenBeforeTable[this.objectType]; if (this.cache == null) { this.cache = new SerObjectInfoCache(this.objectType); this.serObjectInfoInit.seenBeforeTable.Add(this.objectType, this.cache); } }
private void InitNoMembers() { Debug.Assert(_serObjectInfoInit != null && _objectType != null); if (!_serObjectInfoInit._seenBeforeTable.TryGetValue(_objectType, out _cache !)) { _cache = new SerObjectInfoCache(_objectType); _serObjectInfoInit._seenBeforeTable.Add(_objectType, _cache); } }
private void InitNoMembers() { cache = (SerObjectInfoCache)serObjectInfoInit.seenBeforeTable[objectType]; if (cache == null) { SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo new cache"); cache = new SerObjectInfoCache(objectType); serObjectInfoInit.seenBeforeTable.Add(objectType, cache); } }
private void InitNoMembers() { this.cache = (SerObjectInfoCache)this.serObjectInfoInit.seenBeforeTable[(object)this.objectType]; if (this.cache != null) { return; } this.cache = new SerObjectInfoCache(this.objectType); this.serObjectInfoInit.seenBeforeTable.Add((object)this.objectType, (object)this.cache); }
private static void CheckTypeForwardedFrom(SerObjectInfoCache cache, Type objectType, string binderAssemblyString) { if ((cache.hasTypeForwardedFrom && (binderAssemblyString == null)) && !FormatterServices.UnsafeTypeForwardersIsEnabled()) { Assembly assembly = objectType.Assembly; if (!SerializationInfo.IsAssemblyNameAssignmentSafe(assembly.FullName, cache.assemblyString) && !assembly.IsFullyTrusted) { throw new SecurityException(Environment.GetResourceString("Serialization_RequireFullTrust", new object[] { objectType })); } } }
private void InitSiWrite() { SerializationInfoEnumerator?siEnum = null; _isSi = true; Debug.Assert(_si != null); siEnum = _si.GetEnumerator(); int infoLength = 0; infoLength = _si.MemberCount; int count = infoLength; // For ISerializable cache cannot be saved because each object instance can have different values // BinaryWriter only puts the map on the wire if the ISerializable map cannot be reused. TypeInformation?typeInformation = null; string fullTypeName = _si.FullTypeName; string assemblyString = _si.AssemblyName; bool hasTypeForwardedFrom = false; if (!_si.IsFullTypeNameSetExplicit) { typeInformation = BinaryFormatter.GetTypeInformation(_si.ObjectType); fullTypeName = typeInformation.FullTypeName; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } if (!_si.IsAssemblyNameSetExplicit) { if (typeInformation == null) { typeInformation = BinaryFormatter.GetTypeInformation(_si.ObjectType); } assemblyString = typeInformation.AssemblyString; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } _cache = new SerObjectInfoCache(fullTypeName, assemblyString, hasTypeForwardedFrom); _cache._memberNames = new string[count]; _cache._memberTypes = new Type[count]; _memberData = new object[count]; siEnum = _si.GetEnumerator(); for (int i = 0; siEnum.MoveNext(); i++) { _cache._memberNames[i] = siEnum.Name; _cache._memberTypes[i] = siEnum.ObjectType; _memberData[i] = siEnum.Value; } _isNamed = true; }
private void InitNoMembers() { cache = (SerObjectInfoCache)serObjectInfoInit.seenBeforeTable[objectType]; if (cache == null) { SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo new cache"); cache = new SerObjectInfoCache(); cache.fullTypeName = objectType.FullName; cache.assemblyString = objectType.Module.Assembly.FullName; serObjectInfoInit.seenBeforeTable.Add(objectType, cache); } }
[System.Security.SecurityCritical] // auto-generated internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { SerTrace.Log(this, objectInfoId, " Constructor 2 ", objectType); this.objectType = objectType; this.context = context; this.serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { InitNoMembers(); return; } InvokeSerializationBinder(binder); ISurrogateSelector surrogateSelectorTemp = null; if (surrogateSelector != null) { serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp); } if (serializationSurrogate != null) { // surrogate does not have this problem since user has pass in through the BF's ctor si = new SerializationInfo(objectType, converter); cache = new SerObjectInfoCache(objectType); isSi = true; } else if (Object.ReferenceEquals(objectType, Converter.typeofObject)) { } else if (Converter.typeofISerializable.IsAssignableFrom(objectType)) { si = new SerializationInfo(objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled()); cache = new SerObjectInfoCache(objectType); CheckTypeForwardedFrom(cache, objectType, binderAssemblyString); isSi = true; } if (!isSi) { InitMemberInfo(); CheckTypeForwardedFrom(cache, objectType, binderAssemblyString); } SerTrace.Log(this, objectInfoId, " ", objectType, " InitSerialize Exit ", isSi); }
private void InitMemberInfo() { this.cache = new SerObjectInfoCache(this.objectType); this.cache.memberInfos = FormatterServices.GetSerializableMembers(this.objectType, this.context); this.count = this.cache.memberInfos.Length; this.cache.memberNames = new string[this.count]; this.cache.memberTypes = new Type[this.count]; for (int i = 0; i < this.count; i++) { this.cache.memberNames[i] = this.cache.memberInfos[i].Name; this.cache.memberTypes[i] = this.GetMemberType(this.cache.memberInfos[i]); } this.isTyped = true; this.isNamed = true; }
private void InternalInit() { this.obj = (object)null; this.objectType = (Type)null; this.isSi = false; this.isNamed = false; this.isTyped = false; this.isArray = false; this.si = (SerializationInfo)null; this.cache = (SerObjectInfoCache)null; this.memberData = (object[])null; this.objectId = 0L; this.assemId = 0L; this.binderTypeName = (string)null; this.binderAssemblyString = (string)null; }
private void InternalInit() { this.obj = null; this.objectType = null; this.isSi = false; this.isNamed = false; this.isTyped = false; this.isArray = false; this.si = null; this.cache = null; this.memberData = null; this.objectId = 0L; this.assemId = 0L; this.binderTypeName = null; this.binderAssemblyString = null; }
// Write Constructor used for array types or null members internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) { SerTrace.Log(this, objectInfoId, " Constructor 2 ", objectType); this.objectType = objectType; this.context = context; this.serObjectInfoInit = serObjectInfoInit; 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 (objectType == Converter.typeofObject) { } else if (Converter.typeofISerializable.IsAssignableFrom(objectType)) { isSi = true; } if (isSi) { si = new SerializationInfo(objectType, converter); cache = new SerObjectInfoCache(); cache.fullTypeName = si.FullTypeName; cache.assemblyString = si.AssemblyName; } else { InitMemberInfo(); } SerTrace.Log(this, objectInfoId, " ", objectType, " InitSerialize Exit ", isSi); }
private void InitMemberInfo() { _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 < _count; i++) { _cache._memberNames[i] = _cache._memberInfos[i].Name; _cache._memberTypes[i] = GetMemberType(_cache._memberInfos[i]); } _isTyped = true; }
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; }
// Write Constructor used for array types or null members internal void InitSerialize( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type objectType, ISurrogateSelector?surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder?binder) { _objectType = objectType; _context = context; _serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { InitNoMembers(); return; } InvokeSerializationBinder(binder); if (surrogateSelector != null) { _serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out ISurrogateSelector surrogateSelectorTemp); } if (_serializationSurrogate != null) { // surrogate does not have this problem since user has pass in through the BF's ctor _si = new SerializationInfo(objectType, converter); _cache = new SerObjectInfoCache(objectType); _isSi = true; } else if (!ReferenceEquals(objectType, Converter.s_typeofObject) && Converter.s_typeofISerializable.IsAssignableFrom(objectType)) { _si = new SerializationInfo(objectType, converter); _cache = new SerObjectInfoCache(objectType); CheckTypeForwardedFrom(_cache, objectType, _binderAssemblyString); _isSi = true; } if (!_isSi) { InitMemberInfo(); CheckTypeForwardedFrom(_cache, objectType, _binderAssemblyString); } }
private void InitSiWrite() { SerializationInfoEnumerator serializationInfoEnumerator = (SerializationInfoEnumerator)null; this.isSi = true; serializationInfoEnumerator = this.si.GetEnumerator(); int memberCount = this.si.MemberCount; TypeInformation typeInformation = (TypeInformation)null; string fullTypeName = this.si.FullTypeName; string assemblyName = this.si.AssemblyName; bool hasTypeForwardedFrom = false; if (!this.si.IsFullTypeNameSetExplicit) { typeInformation = BinaryFormatter.GetTypeInformation(this.si.ObjectType); fullTypeName = typeInformation.FullTypeName; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } if (!this.si.IsAssemblyNameSetExplicit) { if (typeInformation == null) { typeInformation = BinaryFormatter.GetTypeInformation(this.si.ObjectType); } assemblyName = typeInformation.AssemblyString; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } this.cache = new SerObjectInfoCache(fullTypeName, assemblyName, hasTypeForwardedFrom); this.cache.memberNames = new string[memberCount]; this.cache.memberTypes = new Type[memberCount]; this.memberData = new object[memberCount]; SerializationInfoEnumerator enumerator = this.si.GetEnumerator(); int index = 0; while (enumerator.MoveNext()) { this.cache.memberNames[index] = enumerator.Name; this.cache.memberTypes[index] = enumerator.ObjectType; this.memberData[index] = enumerator.Value; ++index; } this.isNamed = true; this.isTyped = false; }
private static void CheckTypeForwardedFrom(SerObjectInfoCache cache, Type objectType, string binderAssemblyString) { // If we're about to use the [TypeForwardedFrom] attribute for the assembly name if (cache.hasTypeForwardedFrom && binderAssemblyString == null) { if (!FormatterServices.UnsafeTypeForwardersIsEnabled()) { Assembly objectAssembly = objectType.Assembly; // cache.assemblyString will be set to the value of the AssemblyFullName set on the TypeForwardedFrom attribute if (!SerializationInfo.IsAssemblyNameAssignmentSafe(objectAssembly.FullName, cache.assemblyString) && !objectAssembly.IsFullyTrusted) { // if the object assembly is partially trusted, we will block the TypeForwardedFrom case throw new SecurityException(Environment.GetResourceString("Serialization_RequireFullTrust", objectType)); } } } }
private void InternalInit() { _obj = null; _objectType = null; _isSi = false; _isNamed = false; _isArray = false; _si = null; _cache = null; _memberData = null; // Writing and Parsing information _objectId = 0; _assemId = 0; // Binder information _binderTypeName = null; _binderAssemblyString = null; }
private void InternalInit() { SerTrace.Log(this, objectInfoId, " objectType ", objectType, " InternalInit"); objectType = null; count = 0; isSi = false; isNamed = false; isTyped = false; wireMemberNames = null; wireMemberTypes = null; cache = null; lastPosition = 0; // Si Read if (memberTypesList != null) { memberTypesList.Clear(); } }
private void InitMemberInfo() { SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo Entry"); cache = (SerObjectInfoCache)serObjectInfoInit.seenBeforeTable[objectType]; if (cache == null) { SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo new cache"); cache = new SerObjectInfoCache(); cache.memberInfos = FormatterServices.GetSerializableMembers(objectType, context); int count = cache.memberInfos.Length; cache.memberNames = new String[count]; cache.memberTypes = new Type[count]; // Calculate new arrays for (int i = 0; i < count; i++) { cache.memberNames[i] = cache.memberInfos[i].Name; cache.memberTypes[i] = GetMemberType(cache.memberInfos[i]); SerTrace.Log(this, objectInfoId, " InitMemberInfo name ", cache.memberNames[i], ", type ", cache.memberTypes[i], ", memberInfoType ", cache.memberInfos[i].GetType()); } cache.fullTypeName = objectType.FullName; cache.assemblyString = objectType.Assembly.FullName; serObjectInfoInit.seenBeforeTable.Add(objectType, cache); } if (obj != null) { memberData = FormatterServices.GetObjectData(obj, cache.memberInfos); DumpMemberInfo(); } isTyped = true; isNamed = true; SerTrace.Log(this, objectInfoId, " ", objectType, " InitMemberInfo Exit"); }
internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { this.objectType = objectType; this.context = context; this.serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { this.InitNoMembers(); } else { this.InvokeSerializationBinder(binder); ISurrogateSelector selector = (ISurrogateSelector)null; if (surrogateSelector != null) { this.serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out selector); } if (this.serializationSurrogate != null) { this.si = new SerializationInfo(objectType, converter); this.cache = new SerObjectInfoCache(objectType); this.isSi = true; } else if (objectType != Converter.typeofObject && Converter.typeofISerializable.IsAssignableFrom(objectType)) { this.si = new SerializationInfo(objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled()); this.cache = new SerObjectInfoCache(objectType); WriteObjectInfo.CheckTypeForwardedFrom(this.cache, objectType, this.binderAssemblyString); this.isSi = true; } if (this.isSi) { return; } this.InitMemberInfo(); WriteObjectInfo.CheckTypeForwardedFrom(this.cache, objectType, this.binderAssemblyString); } }
private void InitSiWrite() { SerTrace.Log(this, objectInfoId, " InitSiWrite Entry "); SerializationInfoEnumerator siEnum = null; isSi = true; siEnum = si.GetEnumerator(); int infoLength = 0; infoLength = si.MemberCount; int count = infoLength; // For ISerializable cache cannot be saved because each object instance can have different values // BinaryWriter only puts the map on the wire if the ISerializable map cannot be reused. cache = new SerObjectInfoCache(); cache.memberNames = new String[count]; cache.memberTypes = new Type[count]; memberData = new Object[count]; cache.fullTypeName = si.FullTypeName; cache.assemblyString = si.AssemblyName; siEnum = si.GetEnumerator(); for (int i = 0; siEnum.MoveNext(); i++) { cache.memberNames[i] = siEnum.Name; cache.memberTypes[i] = siEnum.ObjectType; memberData[i] = siEnum.Value; SerTrace.Log(this, objectInfoId + " ", objectType, " InitSiWrite ", cache.memberNames[i], " Type ", cache.memberTypes[i], " data ", memberData[i]); } isNamed = true; isTyped = false; SerTrace.Log(this, objectInfoId, " InitSiWrite Exit "); }
private void InitMemberInfo() { this.cache = (SerObjectInfoCache)this.serObjectInfoInit.seenBeforeTable[(object)this.objectType]; if (this.cache == null) { this.cache = new SerObjectInfoCache(this.objectType); this.cache.memberInfos = FormatterServices.GetSerializableMembers(this.objectType, this.context); int length = this.cache.memberInfos.Length; this.cache.memberNames = new string[length]; this.cache.memberTypes = new Type[length]; for (int index = 0; index < length; ++index) { this.cache.memberNames[index] = this.cache.memberInfos[index].Name; this.cache.memberTypes[index] = this.GetMemberType(this.cache.memberInfos[index]); } this.serObjectInfoInit.seenBeforeTable.Add((object)this.objectType, (object)this.cache); } if (this.obj != null) { this.memberData = FormatterServices.GetObjectData(this.obj, this.cache.memberInfos); } this.isTyped = true; this.isNamed = true; }
private void InitNoMembers() { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(objectType); }
private void InitMemberInfo() { this.cache = (SerObjectInfoCache) this.serObjectInfoInit.seenBeforeTable[this.objectType]; if (this.cache == null) { this.cache = new SerObjectInfoCache(this.objectType); this.cache.memberInfos = FormatterServices.GetSerializableMembers(this.objectType, this.context); int length = this.cache.memberInfos.Length; this.cache.memberNames = new string[length]; this.cache.memberTypes = new Type[length]; for (int i = 0; i < length; i++) { this.cache.memberNames[i] = this.cache.memberInfos[i].Name; this.cache.memberTypes[i] = this.GetMemberType(this.cache.memberInfos[i]); } this.serObjectInfoInit.seenBeforeTable.Add(this.objectType, this.cache); } if (this.obj != null) { this.memberData = FormatterServices.GetObjectData(this.obj, this.cache.memberInfos); } this.isTyped = true; this.isNamed = true; }
private void InitNoMembers() { this.cache = (SerObjectInfoCache) this.serObjectInfoInit.seenBeforeTable[this.objectType]; if (this.cache == null) { this.cache = new SerObjectInfoCache(this.objectType); this.serObjectInfoInit.seenBeforeTable.Add(this.objectType, this.cache); } }
private static void CheckTypeForwardedFrom(SerObjectInfoCache cache, Type objectType, string binderAssemblyString) { // nop }
private void InternalInit() { SerTrace.Log( this, objectInfoId," objectType ",objectType," InternalInit"); objectType = null; count = 0; isSi = false; isNamed = false; isTyped = false; wireMemberNames = null; wireMemberTypes = null; cache = null; lastPosition = 0; // Si Read if (memberTypesList != null) { memberTypesList.Clear(); } }
private void InitNoMembers() { cache = (SerObjectInfoCache)serObjectInfoInit.seenBeforeTable[objectType]; if (cache == null) { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(); cache.fullTypeName = objectType.FullName; cache.assemblyString = objectType.Assembly.FullName; serObjectInfoInit.seenBeforeTable.Add(objectType, cache); } }
private void InitNoMembers() { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(); cache.fullTypeName = objectType.FullName; cache.assemblyString = objectType.Assembly.FullName; }
// Write Constructor used for array types or null members internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { _objectType = objectType; _context = context; _serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { InitNoMembers(); return; } InvokeSerializationBinder(binder); ISurrogateSelector surrogateSelectorTemp = null; if (surrogateSelector != null) { _serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp); } if (_serializationSurrogate != null) { // surrogate does not have this problem since user has pass in through the BF's ctor _si = new SerializationInfo(objectType, converter); _cache = new SerObjectInfoCache(objectType); _isSi = true; } else if (!ReferenceEquals(objectType, Converter.s_typeofObject) && Converter.s_typeofISerializable.IsAssignableFrom(objectType)) { _si = new SerializationInfo(objectType, converter); _cache = new SerObjectInfoCache(objectType); CheckTypeForwardedFrom(_cache, objectType, _binderAssemblyString); _isSi = true; } if (!_isSi) { InitMemberInfo(); CheckTypeForwardedFrom(_cache, objectType, _binderAssemblyString); } }
private void InitSiWrite() { SerializationInfoEnumerator siEnum = null; _isSi = true; siEnum = _si.GetEnumerator(); int infoLength = 0; infoLength = _si.MemberCount; int count = infoLength; // For ISerializable cache cannot be saved because each object instance can have different values // BinaryWriter only puts the map on the wire if the ISerializable map cannot be reused. TypeInformation typeInformation = null; string fullTypeName = _si.FullTypeName; string assemblyString = _si.AssemblyName; bool hasTypeForwardedFrom = false; if (!_si.IsFullTypeNameSetExplicit) { typeInformation = BinaryFormatter.GetTypeInformation(_si.ObjectType); fullTypeName = typeInformation.FullTypeName; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } if (!_si.IsAssemblyNameSetExplicit) { if (typeInformation == null) { typeInformation = BinaryFormatter.GetTypeInformation(_si.ObjectType); } assemblyString = typeInformation.AssemblyString; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } _cache = new SerObjectInfoCache(fullTypeName, assemblyString, hasTypeForwardedFrom); _cache._memberNames = new string[count]; _cache._memberTypes = new Type[count]; _memberData = new object[count]; siEnum = _si.GetEnumerator(); for (int i = 0; siEnum.MoveNext(); i++) { _cache._memberNames[i] = siEnum.Name; _cache._memberTypes[i] = siEnum.ObjectType; _memberData[i] = siEnum.Value; } _isNamed = true; }
[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<count; i++) { cache.memberNames[i] = cache.memberInfos[i].Name; cache.memberTypes[i] = GetMemberType(cache.memberInfos[i]); SerTrace.Log( this, objectInfoId," InitMemberInfo name ",cache.memberNames[i],", type ",cache.memberTypes[i],", memberInfoType ",cache.memberInfos[i].GetType()); } isTyped = true; isNamed = true; SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo Exit"); }
private void InitNoMembers() { _cache = new SerObjectInfoCache(_objectType); }
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; }
private void InitSiWrite() { SerTrace.Log( this, objectInfoId," InitSiWrite Entry "); SerializationInfoEnumerator siEnum = null; isSi = true; siEnum = si.GetEnumerator(); int infoLength = 0; infoLength = si.MemberCount; int count = infoLength; // For ISerializable cache cannot be saved because each object instance can have different values // BinaryWriter only puts the map on the wire if the ISerializable map cannot be reused. cache = new SerObjectInfoCache(); cache.memberNames = new String[count]; cache.memberTypes = new Type[count]; memberData = new Object[count]; cache.fullTypeName = si.FullTypeName; cache.assemblyString = si.AssemblyName; siEnum = si.GetEnumerator(); for (int i=0; siEnum.MoveNext(); i++) { cache.memberNames[i] = siEnum.Name; cache.memberTypes[i] = siEnum.ObjectType; memberData[i] = siEnum.Value; SerTrace.Log( this,objectInfoId+" ",objectType," InitSiWrite ",cache.memberNames[i]," Type ",cache.memberTypes[i]," data ",memberData[i]); } isNamed = true; isTyped = false; SerTrace.Log(this, objectInfoId," InitSiWrite Exit "); }
private void InitNoMembers() { this.cache = new SerObjectInfoCache(this.objectType); }
// Write Constructor used for array types or null members internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) { SerTrace.Log( this, objectInfoId," Constructor 2 ",objectType); this.objectType = objectType; this.context = context; this.serObjectInfoInit = serObjectInfoInit; 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 (objectType == Converter.typeofObject) { } else if (Converter.typeofISerializable.IsAssignableFrom(objectType)) isSi = true; if (isSi) { si = new SerializationInfo(objectType, converter); cache = new SerObjectInfoCache(); cache.fullTypeName = si.FullTypeName; cache.assemblyString = si.AssemblyName; } else { InitMemberInfo(); } SerTrace.Log( this,objectInfoId," ", objectType," InitSerialize Exit ",isSi); }
[System.Security.SecurityCritical] // auto-generated internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { SerTrace.Log( this, objectInfoId," Constructor 2 ",objectType); this.objectType = objectType; this.context = context; this.serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { InitNoMembers(); return; } InvokeSerializationBinder(binder); ISurrogateSelector surrogateSelectorTemp = null; if (surrogateSelector!=null) serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp); if (serializationSurrogate != null) { // surrogate does not have this problem since user has pass in through the BF's ctor si = new SerializationInfo(objectType, converter); cache = new SerObjectInfoCache(objectType); isSi = true; } else if (Object.ReferenceEquals(objectType, Converter.typeofObject)) { } else if (Converter.typeofISerializable.IsAssignableFrom(objectType)) { si = new SerializationInfo(objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled()); cache = new SerObjectInfoCache(objectType); CheckTypeForwardedFrom(cache, objectType, binderAssemblyString); isSi = true; } if (!isSi) { InitMemberInfo(); CheckTypeForwardedFrom(cache, objectType, binderAssemblyString); } SerTrace.Log( this,objectInfoId," ", objectType," InitSerialize Exit ",isSi); }
private void InitSiWrite() { SerializationInfoEnumerator enumerator = null; this.isSi = true; enumerator = this.si.GetEnumerator(); int memberCount = this.si.MemberCount; TypeInformation typeInformation = null; string fullTypeName = this.si.FullTypeName; string assemblyName = this.si.AssemblyName; bool hasTypeForwardedFrom = false; if (!this.si.IsFullTypeNameSetExplicit) { typeInformation = BinaryFormatter.GetTypeInformation(this.si.ObjectType); fullTypeName = typeInformation.FullTypeName; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } if (!this.si.IsAssemblyNameSetExplicit) { if (typeInformation == null) { typeInformation = BinaryFormatter.GetTypeInformation(this.si.ObjectType); } assemblyName = typeInformation.AssemblyString; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } this.cache = new SerObjectInfoCache(fullTypeName, assemblyName, hasTypeForwardedFrom); this.cache.memberNames = new string[memberCount]; this.cache.memberTypes = new Type[memberCount]; this.memberData = new object[memberCount]; enumerator = this.si.GetEnumerator(); for (int i = 0; enumerator.MoveNext(); i++) { this.cache.memberNames[i] = enumerator.Name; this.cache.memberTypes[i] = enumerator.ObjectType; this.memberData[i] = enumerator.Value; } this.isNamed = true; this.isTyped = false; }
private void InitSiWrite() { SerTrace.Log( this, objectInfoId," InitSiWrite Entry "); SerializationInfoEnumerator siEnum = null; isSi = true; siEnum = si.GetEnumerator(); int infoLength = 0; infoLength = si.MemberCount; int count = infoLength; // For ISerializable cache cannot be saved because each object instance can have different values // BinaryWriter only puts the map on the wire if the ISerializable map cannot be reused. TypeInformation typeInformation = null; string fullTypeName = si.FullTypeName; string assemblyString = si.AssemblyName; bool hasTypeForwardedFrom = false; if (!si.IsFullTypeNameSetExplicit) { typeInformation = BinaryFormatter.GetTypeInformation(si.ObjectType); fullTypeName = typeInformation.FullTypeName; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } if (!si.IsAssemblyNameSetExplicit) { if (typeInformation == null) { typeInformation = BinaryFormatter.GetTypeInformation(si.ObjectType); } assemblyString = typeInformation.AssemblyString; hasTypeForwardedFrom = typeInformation.HasTypeForwardedFrom; } cache = new SerObjectInfoCache(fullTypeName, assemblyString, hasTypeForwardedFrom); cache.memberNames = new String[count]; cache.memberTypes = new Type[count]; memberData = new Object[count]; siEnum = si.GetEnumerator(); for (int i=0; siEnum.MoveNext(); i++) { cache.memberNames[i] = siEnum.Name; cache.memberTypes[i] = siEnum.ObjectType; memberData[i] = siEnum.Value; SerTrace.Log( this,objectInfoId+" ",objectType," InitSiWrite ",cache.memberNames[i]," Type ",cache.memberTypes[i]," data ",memberData[i]); } isNamed = true; isTyped = false; SerTrace.Log(this, objectInfoId," InitSiWrite Exit "); }
internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder) { this.objectType = objectType; this.context = context; this.serObjectInfoInit = serObjectInfoInit; if (objectType.IsArray) { this.InitNoMembers(); } else { this.InvokeSerializationBinder(binder); ISurrogateSelector selector = null; if (surrogateSelector != null) { this.serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out selector); } if (this.serializationSurrogate != null) { this.si = new SerializationInfo(objectType, converter); this.cache = new SerObjectInfoCache(objectType); this.isSi = true; } else if (!object.ReferenceEquals(objectType, Converter.typeofObject) && Converter.typeofISerializable.IsAssignableFrom(objectType)) { this.si = new SerializationInfo(objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled()); this.cache = new SerObjectInfoCache(objectType); CheckTypeForwardedFrom(this.cache, objectType, this.binderAssemblyString); this.isSi = true; } if (!this.isSi) { this.InitMemberInfo(); CheckTypeForwardedFrom(this.cache, objectType, this.binderAssemblyString); } } }
private void InitNoMembers() { cache = (SerObjectInfoCache)serObjectInfoInit.seenBeforeTable[objectType]; if (cache == null) { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(objectType); serObjectInfoInit.seenBeforeTable.Add(objectType, cache); } }
[System.Security.SecurityCritical] // auto-generated private void InitMemberInfo() { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo Entry"); cache = (SerObjectInfoCache)serObjectInfoInit.seenBeforeTable[objectType]; if (cache == null) { SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo new cache"); cache = new SerObjectInfoCache(objectType); cache.memberInfos = FormatterServices.GetSerializableMembers(objectType, context); int count = cache.memberInfos.Length; cache.memberNames = new String[count]; cache.memberTypes = new Type[count]; // Calculate new arrays for (int i=0; i<count; i++) { cache.memberNames[i] = cache.memberInfos[i].Name; cache.memberTypes[i] = GetMemberType(cache.memberInfos[i]); SerTrace.Log( this, objectInfoId," InitMemberInfo name ",cache.memberNames[i],", type ",cache.memberTypes[i],", memberInfoType ",cache.memberInfos[i].GetType()); } serObjectInfoInit.seenBeforeTable.Add(objectType, cache); } if (obj != null) { memberData = FormatterServices.GetObjectData(obj, cache.memberInfos); DumpMemberInfo(); } isTyped = true; isNamed = true; SerTrace.Log( this,objectInfoId," ", objectType," InitMemberInfo Exit"); }