diff options
Diffstat (limited to 'src/mscorlib/src/System/Runtime/Serialization')
12 files changed, 335 insertions, 234 deletions
diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs index 27f7ecf9d2..52e748db89 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterConverter.cs @@ -12,42 +12,53 @@ ** ** ============================================================*/ -namespace System.Runtime.Serialization { - using System; - using System.Globalization; - using System.Diagnostics.Contracts; - internal class FormatterConverter : IFormatterConverter { +using System; +using System.Globalization; +using System.Diagnostics.Contracts; - public FormatterConverter() { +namespace System.Runtime.Serialization +{ + internal class FormatterConverter : IFormatterConverter + { + public FormatterConverter() + { } - public Object Convert(Object value, Type type) { - if (value==null) { + public Object Convert(Object value, Type type) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ChangeType(value, type, CultureInfo.InvariantCulture); } - public Object Convert(Object value, TypeCode typeCode) { - if (value==null) { + public Object Convert(Object value, TypeCode typeCode) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ChangeType(value, typeCode, CultureInfo.InvariantCulture); } - public bool ToBoolean(Object value) { - if (value==null) { + public bool ToBoolean(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToBoolean(value, CultureInfo.InvariantCulture); } - public char ToChar(Object value) { - if (value==null) { + public char ToChar(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); @@ -55,24 +66,30 @@ namespace System.Runtime.Serialization { } [CLSCompliant(false)] - public sbyte ToSByte(Object value) { - if (value==null) { + public sbyte ToSByte(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToSByte(value, CultureInfo.InvariantCulture); } - public byte ToByte(Object value) { - if (value==null) { + public byte ToByte(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToByte(value, CultureInfo.InvariantCulture); } - public short ToInt16(Object value) { - if (value==null) { + public short ToInt16(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); @@ -80,16 +97,20 @@ namespace System.Runtime.Serialization { } [CLSCompliant(false)] - public ushort ToUInt16(Object value) { - if (value==null) { + public ushort ToUInt16(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToUInt16(value, CultureInfo.InvariantCulture); } - public int ToInt32(Object value) { - if (value==null) { + public int ToInt32(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); @@ -97,16 +118,20 @@ namespace System.Runtime.Serialization { } [CLSCompliant(false)] - public uint ToUInt32(Object value) { - if (value==null) { + public uint ToUInt32(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToUInt32(value, CultureInfo.InvariantCulture); } - public long ToInt64(Object value) { - if (value==null) { + public long ToInt64(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); @@ -114,48 +139,60 @@ namespace System.Runtime.Serialization { } [CLSCompliant(false)] - public ulong ToUInt64(Object value) { - if (value==null) { + public ulong ToUInt64(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToUInt64(value, CultureInfo.InvariantCulture); - } + } - public float ToSingle(Object value) { - if (value==null) { + public float ToSingle(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToSingle(value, CultureInfo.InvariantCulture); } - public double ToDouble(Object value) { - if (value==null) { + public double ToDouble(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToDouble(value, CultureInfo.InvariantCulture); } - public Decimal ToDecimal(Object value) { - if (value==null) { + public Decimal ToDecimal(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToDecimal(value, CultureInfo.InvariantCulture); } - public DateTime ToDateTime(Object value) { - if (value==null) { + public DateTime ToDateTime(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); return System.Convert.ToDateTime(value, CultureInfo.InvariantCulture); } - public String ToString(Object value) { - if (value==null) { + public String ToString(Object value) + { + if (value == null) + { throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); @@ -163,4 +200,4 @@ namespace System.Runtime.Serialization { } } } - + diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs index c3f9eb4452..d1669b976f 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs @@ -11,25 +11,26 @@ ** ** ============================================================*/ -namespace System.Runtime.Serialization { - - using System; - using System.Reflection; - using System.Collections; - using System.Collections.Generic; - using System.Security; - using System.Runtime.Remoting; - using System.Runtime.CompilerServices; - using System.Runtime.Versioning; - using System.Threading; - using System.IO; - using System.Text; - using System.Globalization; - using System.Diagnostics; - using System.Diagnostics.Contracts; - public static class FormatterServices { - +using System; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using System.Security; +using System.Runtime.Remoting; +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using System.Threading; +using System.IO; +using System.Text; +using System.Globalization; +using System.Diagnostics; +using System.Diagnostics.Contracts; + +namespace System.Runtime.Serialization +{ + public static class FormatterServices + { // Gets a new instance of the object. The entire object is initalized to 0 and no // constructors have been run. **THIS MEANS THAT THE OBJECT MAY NOT BE IN A STATE // CONSISTENT WITH ITS INTERNAL REQUIREMENTS** This method should only be used for @@ -37,23 +38,26 @@ namespace System.Runtime.Serialization { // will not create an unitialized string because it is non-sensical to create an empty // instance of an immutable type. // - public static Object GetUninitializedObject(Type type) { - if ((object)type == null) { + public static Object GetUninitializedObject(Type type) + { + if ((object)type == null) + { throw new ArgumentNullException(nameof(type)); } Contract.EndContractBlock(); - - if (!(type is RuntimeType)) { + + if (!(type is RuntimeType)) + { throw new SerializationException(Environment.GetResourceString("Serialization_InvalidType", type.ToString())); } return nativeGetUninitializedObject((RuntimeType)type); } - + [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern Object nativeGetUninitializedObject(RuntimeType type); private static Binder s_binder = Type.DefaultBinder; - + /*============================LoadAssemblyFromString============================ **Action: Loads an assembly from a given string. The current assembly loading story ** is quite confusing. If the assembly is in the fusion cache, we can load it @@ -65,7 +69,8 @@ namespace System.Runtime.Serialization { **Arguments: assemblyName -- The stringized assembly name. **Exceptions: None ==============================================================================*/ - internal static Assembly LoadAssemblyFromString(String assemblyName) { + internal static Assembly LoadAssemblyFromString(String assemblyName) + { // // Try using the stringized assembly name to load from the fusion cache. // diff --git a/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs b/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs index 2911a4016e..2b07ce9c38 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/IDeserializationCallback.cs @@ -12,11 +12,14 @@ ** ** ===========================================================*/ -namespace System.Runtime.Serialization { - using System; +using System; + +namespace System.Runtime.Serialization +{ // Interface does not need to be marked with the serializable attribute - public interface IDeserializationCallback { + public interface IDeserializationCallback + { void OnDeserialization(Object sender); } } diff --git a/src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs b/src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs index 0be0db9acd..1f6f682ee2 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/IFormatterConverter.cs @@ -13,27 +13,30 @@ ** ** ============================================================*/ -namespace System.Runtime.Serialization { - using System; +using System; + +namespace System.Runtime.Serialization +{ [CLSCompliant(false)] - public interface IFormatterConverter { + public interface IFormatterConverter + { Object Convert(Object value, Type type); Object Convert(Object value, TypeCode typeCode); - bool ToBoolean(Object value); - char ToChar(Object value); - sbyte ToSByte(Object value); - byte ToByte(Object value); - short ToInt16(Object value); + bool ToBoolean(Object value); + char ToChar(Object value); + sbyte ToSByte(Object value); + byte ToByte(Object value); + short ToInt16(Object value); ushort ToUInt16(Object value); - int ToInt32(Object value); - uint ToUInt32(Object value); - long ToInt64(Object value); - ulong ToUInt64(Object value); - float ToSingle(Object value); + int ToInt32(Object value); + uint ToUInt32(Object value); + long ToInt64(Object value); + ulong ToUInt64(Object value); + float ToSingle(Object value); double ToDouble(Object value); Decimal ToDecimal(Object value); DateTime ToDateTime(Object value); - String ToString(Object value); + String ToString(Object value); } } diff --git a/src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs b/src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs index ef5ee6ade0..b07f26fe09 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/IObjectReference.cs @@ -15,11 +15,14 @@ ** ** ===========================================================*/ -namespace System.Runtime.Serialization { - using System; +using System; + +namespace System.Runtime.Serialization +{ // Interface does not need to be marked with the serializable attribute - public interface IObjectReference { + public interface IObjectReference + { Object GetRealObject(StreamingContext context); } } diff --git a/src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs b/src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs index 816aa0484b..4e5873b817 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/ISerializable.cs @@ -13,16 +13,17 @@ ** ===========================================================*/ -namespace System.Runtime.Serialization { - using System.Runtime.Remoting; - using System.Runtime.Serialization; - using System; - using System.Reflection; - - public interface ISerializable { +using System.Runtime.Remoting; +using System.Runtime.Serialization; +using System; +using System.Reflection; + +namespace System.Runtime.Serialization +{ + public interface ISerializable + { void GetObjectData(SerializationInfo info, StreamingContext context); } - } diff --git a/src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs b/src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs index 260e873bc7..45173db4f9 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SafeSerializationManager.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. + using System; using System.Collections; using System.Collections.Generic; @@ -211,7 +212,7 @@ namespace System.Runtime.Serialization private StreamingContext m_streamingContext; private List<object> m_serializedStates = new List<object>(); - internal SafeSerializationEventArgs() {} + internal SafeSerializationEventArgs() { } public void AddSerializedState(ISafeSerializationData serializedState) { diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs index 38abffa66e..435ca279e4 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs @@ -10,50 +10,52 @@ ** ** ============================================================*/ + +using System; +using System.Diagnostics.Contracts; +using System.Reflection; + namespace System.Runtime.Serialization { - using System; - using System.Diagnostics.Contracts; - using System.Reflection; - - [AttributeUsage(AttributeTargets.Field, Inherited=false)] - public sealed class OptionalFieldAttribute : Attribute + [AttributeUsage(AttributeTargets.Field, Inherited = false)] + public sealed class OptionalFieldAttribute : Attribute { - int versionAdded = 1; + private int versionAdded = 1; public OptionalFieldAttribute() { } - - public int VersionAdded + + public int VersionAdded { - get { - return this.versionAdded; + get + { + return versionAdded; } - set { + set + { if (value < 1) throw new ArgumentException(Environment.GetResourceString("Serialization_OptionalFieldVersionValue")); Contract.EndContractBlock(); - this.versionAdded = value; + versionAdded = value; } } } - [AttributeUsage(AttributeTargets.Method, Inherited=false)] - public sealed class OnSerializingAttribute : Attribute + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class OnSerializingAttribute : Attribute { } - [AttributeUsage(AttributeTargets.Method, Inherited=false)] - public sealed class OnSerializedAttribute : Attribute + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class OnSerializedAttribute : Attribute { } - [AttributeUsage(AttributeTargets.Method, Inherited=false)] - public sealed class OnDeserializingAttribute : Attribute + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class OnDeserializingAttribute : Attribute { } - [AttributeUsage(AttributeTargets.Method, Inherited=false)] - public sealed class OnDeserializedAttribute : Attribute + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class OnDeserializedAttribute : Attribute { } - } diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs index e9cb79b7af..65db0e930a 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs @@ -12,33 +12,38 @@ ** =============================================================================*/ -namespace System.Runtime.Serialization { - - using System; - using System.Runtime.Serialization; +using System; +using System.Runtime.Serialization; + +namespace System.Runtime.Serialization +{ [Serializable] - public class SerializationException : SystemException { - + public class SerializationException : SystemException + { private static String _nullMessage = Environment.GetResourceString("Arg_SerializationException"); - + // Creates a new SerializationException with its message // string set to a default message. - public SerializationException() - : base(_nullMessage) { + public SerializationException() + : base(_nullMessage) + { SetErrorCode(__HResults.COR_E_SERIALIZATION); } - - public SerializationException(String message) - : base(message) { + + public SerializationException(String message) + : base(message) + { SetErrorCode(__HResults.COR_E_SERIALIZATION); } - public SerializationException(String message, Exception innerException) : base (message, innerException) { + public SerializationException(String message, Exception innerException) : base(message, innerException) + { SetErrorCode(__HResults.COR_E_SERIALIZATION); } - protected SerializationException(SerializationInfo info, StreamingContext context) : base (info, context) { + protected SerializationException(SerializationInfo info, StreamingContext context) : base(info, context) + { } } } diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs index 45521f2397..d024361985 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs @@ -11,25 +11,25 @@ ** ** ===========================================================*/ -namespace System.Runtime.Serialization -{ - using System; - using System.Collections.Generic; - using System.Reflection; - using System.Runtime.Remoting; - using System.Globalization; - using System.Diagnostics; - using System.Diagnostics.Contracts; - using System.Security; - using System.Runtime.CompilerServices; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.Remoting; +using System.Globalization; +using System.Diagnostics; +using System.Diagnostics.Contracts; +using System.Security; +using System.Runtime.CompilerServices; +namespace System.Runtime.Serialization +{ public sealed class SerializationInfo { private const int defaultSize = 4; private const string s_mscorlibAssemblySimpleName = System.CoreLib.Name; private const string s_mscorlibFileName = s_mscorlibAssemblySimpleName + ".dll"; - + // Even though we have a dictionary, we're still keeping all the arrays around for back-compat. // Otherwise we may run into potentially breaking behaviors like GetEnumerator() not returning entries in the same order they were added. internal String[] m_members; @@ -94,7 +94,7 @@ namespace System.Runtime.Serialization throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); - + m_fullTypeName = value; isFullTypeNameSetExplicit = true; } @@ -113,9 +113,9 @@ namespace System.Runtime.Serialization throw new ArgumentNullException(nameof(value)); } Contract.EndContractBlock(); - if (this.requireSameTokenInPartialTrust) + if (requireSameTokenInPartialTrust) { - DemandForUnsafeAssemblyNameAssignments(this.m_assemName, value); + DemandForUnsafeAssemblyNameAssignments(m_assemName, value); } m_assemName = value; isAssemblyNameSetExplicit = true; @@ -130,7 +130,7 @@ namespace System.Runtime.Serialization } Contract.EndContractBlock(); - if (this.requireSameTokenInPartialTrust) + if (requireSameTokenInPartialTrust) { DemandForUnsafeAssemblyNameAssignments(this.ObjectType.Assembly.FullName, type.Assembly.FullName); } @@ -382,7 +382,6 @@ namespace System.Runtime.Serialization m_data[index] = value; m_types[index] = type; } - } private int FindElement(String name) @@ -451,7 +450,6 @@ namespace System.Runtime.Serialization public Object GetValue(String name, Type type) { - if ((object)type == null) { throw new ArgumentNullException(nameof(type)); @@ -698,6 +696,5 @@ namespace System.Runtime.Serialization } return m_converter.ToString(value); } - } } diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs index 0858dfc19f..b7857dece2 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs @@ -12,39 +12,49 @@ ** ** ============================================================*/ -namespace System.Runtime.Serialization { - using System; - using System.Diagnostics; - using System.Collections; - using System.Diagnostics.Contracts; +using System; +using System.Diagnostics; +using System.Collections; +using System.Diagnostics.Contracts; + +namespace System.Runtime.Serialization +{ // // The tuple returned by SerializationInfoEnumerator.Current. // - public struct SerializationEntry { - private Type m_type; + public struct SerializationEntry + { + private Type m_type; private Object m_value; private String m_name; - public Object Value { - get { + public Object Value + { + get + { return m_value; } } - public String Name { - get { + public String Name + { + get + { return m_name; } } - public Type ObjectType { - get { + public Type ObjectType + { + get + { return m_type; } } - internal SerializationEntry(String entryName, Object entryValue, Type entryType) { + internal SerializationEntry(String entryName, Object entryValue, Type entryType) + { m_value = entryValue; m_name = entryName; m_type = entryType; @@ -56,86 +66,108 @@ namespace System.Runtime.Serialization { // This does not snapshot the values, it just keeps pointers to the // member variables of the SerializationInfo that created it. // - public sealed class SerializationInfoEnumerator : IEnumerator { - String[] m_members; - Object[] m_data; - Type[] m_types; - int m_numItems; - int m_currItem; - bool m_current; + public sealed class SerializationInfoEnumerator : IEnumerator + { + private String[] m_members; + private Object[] m_data; + private Type[] m_types; + private int m_numItems; + private int m_currItem; + private bool m_current; - internal SerializationInfoEnumerator(String[] members, Object[] info, Type[] types, int numItems) { - Debug.Assert(members!=null, "[SerializationInfoEnumerator.ctor]members!=null"); - Debug.Assert(info!=null, "[SerializationInfoEnumerator.ctor]info!=null"); - Debug.Assert(types!=null, "[SerializationInfoEnumerator.ctor]types!=null"); - Debug.Assert(numItems>=0, "[SerializationInfoEnumerator.ctor]numItems>=0"); - Debug.Assert(members.Length>=numItems, "[SerializationInfoEnumerator.ctor]members.Length>=numItems"); - Debug.Assert(info.Length>=numItems, "[SerializationInfoEnumerator.ctor]info.Length>=numItems"); - Debug.Assert(types.Length>=numItems, "[SerializationInfoEnumerator.ctor]types.Length>=numItems"); + internal SerializationInfoEnumerator(String[] members, Object[] info, Type[] types, int numItems) + { + Debug.Assert(members != null, "[SerializationInfoEnumerator.ctor]members!=null"); + Debug.Assert(info != null, "[SerializationInfoEnumerator.ctor]info!=null"); + Debug.Assert(types != null, "[SerializationInfoEnumerator.ctor]types!=null"); + Debug.Assert(numItems >= 0, "[SerializationInfoEnumerator.ctor]numItems>=0"); + Debug.Assert(members.Length >= numItems, "[SerializationInfoEnumerator.ctor]members.Length>=numItems"); + Debug.Assert(info.Length >= numItems, "[SerializationInfoEnumerator.ctor]info.Length>=numItems"); + Debug.Assert(types.Length >= numItems, "[SerializationInfoEnumerator.ctor]types.Length>=numItems"); m_members = members; m_data = info; m_types = types; //The MoveNext semantic is much easier if we enforce that [0..m_numItems] are valid entries //in the enumerator, hence we subtract 1. - m_numItems = numItems-1; + m_numItems = numItems - 1; m_currItem = -1; m_current = false; } - public bool MoveNext() { - if (m_currItem<m_numItems) { + public bool MoveNext() + { + if (m_currItem < m_numItems) + { m_currItem++; m_current = true; - } else { + } + else + { m_current = false; } return m_current; } /// <internalonly/> - Object IEnumerator.Current { //Actually returns a SerializationEntry - get { - if (m_current==false) { + Object IEnumerator.Current + { //Actually returns a SerializationEntry + get + { + if (m_current == false) + { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } return (Object)(new SerializationEntry(m_members[m_currItem], m_data[m_currItem], m_types[m_currItem])); } } - public SerializationEntry Current { //Actually returns a SerializationEntry - get { - if (m_current==false) { + public SerializationEntry Current + { //Actually returns a SerializationEntry + get + { + if (m_current == false) + { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } return (new SerializationEntry(m_members[m_currItem], m_data[m_currItem], m_types[m_currItem])); } } - public void Reset() { + public void Reset() + { m_currItem = -1; m_current = false; } - public String Name { - get { - if (m_current==false) { + public String Name + { + get + { + if (m_current == false) + { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } return m_members[m_currItem]; } } - public Object Value { - get { - if (m_current==false) { + public Object Value + { + get + { + if (m_current == false) + { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } return m_data[m_currItem]; } } - public Type ObjectType { - get { - if (m_current==false) { + public Type ObjectType + { + get + { + if (m_current == false) + { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); } return m_types[m_currItem]; diff --git a/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs b/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs index c01a3edc4f..12a7631714 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/StreamingContext.cs @@ -11,62 +11,74 @@ ** ** ===========================================================*/ -namespace System.Runtime.Serialization { - using System.Runtime.Remoting; - using System; +using System.Runtime.Remoting; +using System; + +namespace System.Runtime.Serialization +{ [Serializable] - public struct StreamingContext { + public struct StreamingContext + { internal Object m_additionalContext; internal StreamingContextStates m_state; - - public StreamingContext(StreamingContextStates state) - : this (state, null) { + + public StreamingContext(StreamingContextStates state) + : this(state, null) + { } - - public StreamingContext(StreamingContextStates state, Object additional) { + + public StreamingContext(StreamingContextStates state, Object additional) + { m_state = state; m_additionalContext = additional; } - - public Object Context { + + public Object Context + { get { return m_additionalContext; } } - - public override bool Equals(Object obj) { - if (!(obj is StreamingContext)) { + + public override bool Equals(Object obj) + { + if (!(obj is StreamingContext)) + { return false; } if (((StreamingContext)obj).m_additionalContext == m_additionalContext && - ((StreamingContext)obj).m_state == m_state) { + ((StreamingContext)obj).m_state == m_state) + { return true; - } + } return false; } - - public override int GetHashCode() { + + public override int GetHashCode() + { return (int)m_state; } - - public StreamingContextStates State { - get { return m_state; } + + public StreamingContextStates State + { + get { return m_state; } } } - + // ********************************************************** // Keep these in sync with the version in vm\runtimehandles.h // ********************************************************** -[Serializable] -[Flags] - public enum StreamingContextStates { - CrossProcess=0x01, - CrossMachine=0x02, - File =0x04, - Persistence =0x08, - Remoting =0x10, - Other =0x20, - Clone =0x40, - CrossAppDomain =0x80, - All =0xFF, + [Serializable] + [Flags] + public enum StreamingContextStates + { + CrossProcess = 0x01, + CrossMachine = 0x02, + File = 0x04, + Persistence = 0x08, + Remoting = 0x10, + Other = 0x20, + Clone = 0x40, + CrossAppDomain = 0x80, + All = 0xFF, } } |