-Subproject commit fb151e4afeffea5753b84674c888eaa7b274b51e
+Subproject commit 8cbddd1eec236af973d4d9dcb623a4dccde91d52
public static void Trace (string switchName, params object[]messages)
{
}
+
+ internal static bool CheckEnabled (string switchName)
+ {
+ return false;
+ }
}
}
--- /dev/null
+using System.Collections;
+using System.Diagnostics.Contracts;
+
+namespace System.Runtime.Remoting.Messaging
+{
+ //+================================================================================
+ //
+ // Synopsis: Abstract class to help present a dictionary view of an object
+ //
+ //-================================================================================
+ internal abstract class MessageDictionary : IDictionary
+ {
+ internal String[] _keys;
+ internal IDictionary _dict;
+
+ internal MessageDictionary(String[] keys, IDictionary idict)
+ {
+ _keys = keys;
+ _dict = idict;
+ }
+
+ internal bool HasUserData()
+ {
+ // used by message smuggler to determine if there is any custom user
+ // data in the dictionary
+ if ((_dict != null) && (_dict.Count > 0))
+ return true;
+ else
+ return false;
+ }
+
+ // used by message smuggler, so that it doesn't have to iterate
+ // through special keys
+ internal IDictionary InternalDictionary
+ {
+ get { return _dict; }
+ }
+
+
+ internal abstract Object GetMessageValue(int i);
+
+ [System.Security.SecurityCritical]
+ internal abstract void SetSpecialKey(int keyNum, Object value);
+
+ public virtual bool IsReadOnly { get { return false; } }
+ public virtual bool IsSynchronized { get { return false; } }
+ public virtual bool IsFixedSize { get { return false; } }
+
+ public virtual Object SyncRoot { get { return this; } }
+
+
+ public virtual bool Contains(Object key)
+ {
+ if (ContainsSpecialKey(key))
+ {
+ return true;
+ }
+ else if (_dict != null)
+ {
+ return _dict.Contains(key);
+ }
+ return false;
+ }
+
+ protected virtual bool ContainsSpecialKey(Object key)
+ {
+ if (!(key is System.String))
+ {
+ return false;
+ }
+ String skey = (String) key;
+ for (int i = 0 ; i < _keys.Length; i++)
+ {
+ if (skey.Equals(_keys[i]))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public virtual void CopyTo(Array array, int index)
+ {
+ for (int i=0; i<_keys.Length; i++)
+ {
+ array.SetValue(GetMessageValue(i), index+i);
+ }
+
+ if (_dict != null)
+ {
+ _dict.CopyTo(array, index+_keys.Length);
+ }
+ }
+
+ public virtual Object this[Object key]
+ {
+ get
+ {
+ System.String skey = key as System.String;
+ if (null != skey)
+ {
+ for (int i=0; i<_keys.Length; i++)
+ {
+ if (skey.Equals(_keys[i]))
+ {
+ return GetMessageValue(i);
+ }
+ }
+ if (_dict != null)
+ {
+ return _dict[key];
+ }
+ }
+ return null;
+ }
+ [System.Security.SecuritySafeCritical] // TODO: review - implements transparent public method
+ set
+ {
+ if (ContainsSpecialKey(key))
+ {
+ if (key.Equals(MonoMethodMessage.UriKey))
+ {
+ SetSpecialKey(0,value);
+ }
+ else if (key.Equals(MonoMethodMessage.CallContextKey))
+ {
+ SetSpecialKey(1,value);
+ }
+ else
+ {
+ throw new ArgumentException(
+ Environment.GetResourceString(
+ "Argument_InvalidKey"));
+ }
+ }
+ else
+ {
+ if (_dict == null)
+ {
+ _dict = new Hashtable();
+ }
+ _dict[key] = value;
+ }
+
+ }
+ }
+
+ IDictionaryEnumerator IDictionary.GetEnumerator()
+ {
+ return new MessageDictionaryEnumerator(this, _dict);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ throw new NotSupportedException();
+ }
+
+
+ public virtual void Add(Object key, Object value)
+ {
+ if (ContainsSpecialKey(key))
+ {
+ throw new ArgumentException(
+ Environment.GetResourceString(
+ "Argument_InvalidKey"));
+ }
+ else
+ {
+ if (_dict == null)
+ {
+ // no need to interlock, message object not guaranteed to
+ // be thread-safe.
+ _dict = new Hashtable();
+ }
+ _dict.Add(key, value);
+ }
+ }
+
+ public virtual void Clear()
+ {
+ // Remove all the entries from the hash table
+ if (null != _dict)
+ {
+ _dict.Clear();
+ }
+ }
+
+ public virtual void Remove(Object key)
+ {
+ if (ContainsSpecialKey(key) || (_dict == null))
+ {
+ throw new ArgumentException(
+ Environment.GetResourceString(
+ "Argument_InvalidKey"));
+ }
+ else
+ {
+ _dict.Remove(key);
+ }
+ }
+
+ public virtual ICollection Keys
+ {
+ get
+ {
+
+ int len = _keys.Length;
+ ICollection c = (_dict != null) ? _dict.Keys : null;
+ if (c != null)
+ {
+ len += c.Count;
+ }
+
+ ArrayList l = new ArrayList(len);
+ for (int i = 0; i<_keys.Length; i++)
+ {
+ l.Add(_keys[i]);
+ }
+
+ if (c != null)
+ {
+ l.AddRange(c);
+ }
+
+ return l;
+ }
+ }
+
+ public virtual ICollection Values
+ {
+ get
+ {
+ int len = _keys.Length;
+ ICollection c = (_dict != null) ? _dict.Keys : null;
+ if (c != null)
+ {
+ len += c.Count;
+ }
+
+ ArrayList l = new ArrayList(len);
+
+ for (int i = 0; i<_keys.Length; i++)
+ {
+ l.Add(GetMessageValue(i));
+ }
+
+ if (c != null)
+ {
+ l.AddRange(c);
+ }
+ return l;
+ }
+ }
+
+ public virtual int Count
+ {
+ get
+ {
+ if (_dict != null)
+ {
+ return _dict.Count+_keys.Length;
+ }
+ else
+ {
+ return _keys.Length;
+ }
+ }
+ }
+
+ }
+
+ //+================================================================================
+ //
+ // Synopsis: Dictionary enumerator for helper class
+ //
+ //-================================================================================
+ internal class MessageDictionaryEnumerator : IDictionaryEnumerator
+ {
+ private int i=-1;
+ private IDictionaryEnumerator _enumHash;
+ private MessageDictionary _md;
+
+
+ public MessageDictionaryEnumerator(MessageDictionary md, IDictionary hashtable)
+ {
+ _md = md;
+ if (hashtable != null)
+ {
+ _enumHash = hashtable.GetEnumerator();
+ }
+ else
+ {
+ _enumHash = null;
+ }
+ }
+ // Returns the key of the current element of the enumeration. The returned
+ // value is undefined before the first call to GetNext and following
+ // a call to GetNext that returned false. Multiple calls to
+ // GetKey with no intervening calls to GetNext will return
+ // the same object.
+ //
+ public Object Key {
+ get {
+ if (i < 0)
+ {
+ throw new InvalidOperationException(
+ Environment.GetResourceString(
+ "InvalidOperation_InternalState"));
+ }
+ if (i < _md._keys.Length)
+ {
+ return _md._keys[i];
+ }
+ else
+ {
+ Contract.Assert(_enumHash != null,"_enumHash != null");
+ return _enumHash.Key;
+ }
+ }
+ }
+
+ // Returns the value of the current element of the enumeration. The
+ // returned value is undefined before the first call to GetNext and
+ // following a call to GetNext that returned false. Multiple calls
+ // to GetValue with no intervening calls to GetNext will
+ // return the same object.
+ //
+ public Object Value {
+ get {
+ if (i < 0)
+ {
+ throw new InvalidOperationException(
+ Environment.GetResourceString(
+ "InvalidOperation_InternalState"));
+ }
+
+ if (i < _md._keys.Length)
+ {
+ return _md.GetMessageValue(i);
+ }
+ else
+ {
+ Contract.Assert(_enumHash != null,"_enumHash != null");
+ return _enumHash.Value;
+ }
+ }
+ }
+
+ // Advances the enumerator to the next element of the enumeration and
+ // returns a boolean indicating whether an element is available. Upon
+ // creation, an enumerator is conceptually positioned before the first
+ // element of the enumeration, and the first call to GetNext brings
+ // the first element of the enumeration into view.
+ //
+ public bool MoveNext()
+ {
+ if (i == -2)
+ {
+ throw new InvalidOperationException(
+ Environment.GetResourceString(
+ "InvalidOperation_InternalState"));
+ }
+ i++;
+ if (i < _md._keys.Length)
+ {
+ return true;
+ }
+ else
+ {
+ if (_enumHash != null && _enumHash.MoveNext())
+ {
+ return true;
+ }
+ else
+ {
+ i = -2;
+ return false;
+ }
+ }
+ }
+
+ // Returns the current element of the enumeration. The returned value is
+ // undefined before the first call to MoveNext and following a call
+ // to MoveNext that returned false. Multiple calls to
+ // Current with no intervening calls to MoveNext will return
+ // the same object.
+ //
+ public Object Current {
+ get {
+ return Entry;
+ }
+ }
+
+ public DictionaryEntry Entry {
+ get {
+ return new DictionaryEntry(Key, Value);
+ }
+ }
+
+ // Resets the enumerator, positioning it before the first element. If an
+ // Enumerator doesn't support Reset, a NotSupportedException is
+ // thrown.
+ public void Reset()
+ {
+ i = -1;
+ if (_enumHash != null)
+ {
+ _enumHash.Reset();
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace System.Runtime.Remoting.Metadata
+{
+ class RemotingCachedData
+ {
+
+ }
+
+ class RemotingFieldCachedData
+ {
+ internal RemotingFieldCachedData(RuntimeFieldInfo ri)
+ {
+ }
+
+ internal RemotingFieldCachedData(SerializationFieldInfo ri)
+ {
+ }
+ }
+}
\ No newline at end of file
#endif
using System.Diagnostics.Contracts;
using System.Security;
+using System.Runtime.Serialization;
namespace System
{
return att.Length != 0 ? ((DefaultMemberAttribute) att [0]).MemberName : null;
}
+ RuntimeConstructorInfo m_serializationCtor;
+ internal RuntimeConstructorInfo GetSerializationCtor()
+ {
+ if (m_serializationCtor == null) {
+ var s_SICtorParamTypes = new Type[] { typeof(SerializationInfo), typeof(StreamingContext) };
+
+ m_serializationCtor = GetConstructor(
+ BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
+ null,
+ CallingConventions.Any,
+ s_SICtorParamTypes,
+ null) as RuntimeConstructorInfo;
+ }
+
+ return m_serializationCtor;
+ }
+
internal Object CreateInstanceSlow(bool publicOnly, bool skipCheckThis, bool fillCache, ref StackCrawlMark stackMark)
{
bool bNeedSecurityCheck = true;
get { return get_core_clr_security_level () == 1; }
}
}
-}
\ No newline at end of file
+}
return (RuntimeAssembly) Assembly.Load (assemblyRef);
}
+
+ internal static RuntimeAssembly LoadWithPartialNameInternal (String partialName, Evidence securityEvidence, ref StackCrawlMark stackMark)
+ {
+ AssemblyName an = new AssemblyName(partialName);
+ return LoadWithPartialNameInternal (an, securityEvidence, ref stackMark);
+ }
+
+ internal static RuntimeAssembly LoadWithPartialNameInternal (AssemblyName an, Evidence securityEvidence, ref StackCrawlMark stackMark)
+ {
+ throw new NotImplementedException ("LoadWithPartialNameInternal");
+ }
}
[ComVisible (true)]
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
+using System.Diagnostics;
namespace System.Reflection {
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern object UnsafeGetValue (object obj);
+
+ internal void CheckConsistency(Object target)
+ {
+ // only test instance fields
+ if ((Attributes & FieldAttributes.Static) != FieldAttributes.Static)
+ {
+ if (!DeclaringType.IsInstanceOfType(target))
+ {
+ if (target == null)
+ {
+#if FEATURE_LEGACYNETCF
+ if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
+ throw new ArgumentNullException(Environment.GetResourceString("RFLCT.Targ_StatFldReqTarg"));
+ else
+#endif
+ throw new TargetException(Environment.GetResourceString("RFLCT.Targ_StatFldReqTarg"));
+ }
+ else
+ {
+ throw new ArgumentException(
+ String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_FieldDeclTarget"),
+ Name, DeclaringType, target.GetType()));
+ }
+ }
+ }
+ }
+
+ [DebuggerStepThroughAttribute]
+ [Diagnostics.DebuggerHidden]
+ internal void UnsafeSetValue (Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
+ {
+ bool domainInitialized = false;
+ RuntimeFieldHandle.SetValue (this, obj, value, null, Attributes, null, ref domainInitialized);
+ }
}
[Serializable]
return 0;
}
}
+
+ internal void SerializationInvoke (Object target, SerializationInfo info, StreamingContext context)
+ {
+ Invoke (target, new object[] { info, context });
+ }
}
[Serializable()]
namespace System.Reflection
{
+ abstract class RuntimeParameterInfo : ParameterInfo
+ {
+
+ }
+
[ComVisible (true)]
[ComDefaultInterfaceAttribute (typeof (_ParameterInfo))]
[Serializable]
[ClassInterfaceAttribute (ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
- class MonoParameterInfo : ParameterInfo {
+ class MonoParameterInfo : RuntimeParameterInfo {
#if !FULL_AOT_RUNTIME
internal MonoParameterInfo (ParameterBuilder pb, Type type, MemberInfo member, int position) {
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;\r
-using System.Runtime.Remoting;\r
-\r
-namespace System.Runtime.Remoting.Messaging\r
-{\r
- internal interface IInternalMessage\r
- {\r
- Identity TargetIdentity { get; set; }\r
- string Uri { get; set; }\r
- }\r
-}\r
+using System;
+using System.Runtime.Remoting;
+
+namespace System.Runtime.Remoting.Messaging
+{
+ internal interface IInternalMessage
+ {
+ Identity TargetIdentity { get; set; }
+ string Uri { get; set; }
+ bool HasProperties();
+ }
+}
get { return _data; }
set { _data = value; }
}
+
+ internal CallContextRemotingData RemotingData {
+ get {
+ return _remotingData;
+ }
+ }
}
[Serializable]
using System.Collections;
using System.Reflection;
using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
namespace System.Runtime.Remoting.Messaging {
ResolveMethod();
}
+ internal MethodCall (Object handlerObject, BinaryMethodCallMessage smuggledMsg)
+ {
+ if (handlerObject != null)
+ {
+ _uri = handlerObject as String;
+ if (_uri == null)
+ {
+ // This must be the tranparent proxy
+ MarshalByRefObject mbr = handlerObject as MarshalByRefObject;
+ if (mbr != null)
+ {
+ throw new NotImplementedException ("MarshalByRefObject.GetIdentity");
+/*
+ bool fServer;
+ srvID = MarshalByRefObject.GetIdentity(mbr, out fServer) as ServerIdentity;
+ uri = srvID.URI;
+*/
+ }
+ }
+ }
+
+ _typeName = smuggledMsg.TypeName;
+ _methodName = smuggledMsg.MethodName;
+ _methodSignature = (Type[])smuggledMsg.MethodSignature;
+ _args = smuggledMsg.Args;
+ _genericArguments = smuggledMsg.InstantiationArgs;
+ _callContext = smuggledMsg.LogicalCallContext;
+
+ ResolveMethod();
+
+ if (smuggledMsg.HasProperties)
+ smuggledMsg.PopulateMessageProperties(Properties);
+ }
+
internal MethodCall ()
{
}
set { _targetIdentity = value; }
}
+ bool IInternalMessage.HasProperties()
+ {
+ return (ExternalProperties != null) || (InternalProperties != null);
+ }
+
Type[] GenericArguments {
get {
if (_genericArguments != null)
case "__OutArgs":
case "__Return": return;
- case "__MethodName" :
- case "__TypeName" :
- case "__MethodSignature" :
- case "__Args" : throw new ArgumentException ("key was invalid");
+ case "__MethodName" :
+ case "__TypeName" :
+ case "__MethodSignature" :
+ case "__Args" : return; //throw new ArgumentException ("key was invalid " + key);
case "__Uri": ((IInternalMessage)_message).Uri = (string) value; return;
}
}
public object Current
{
- get {return Entry.Value; }
+ get {return Entry; }
}
public bool MoveNext()
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
namespace System.Runtime.Remoting.Messaging {
CADMessageBase.UnmarshalProperties (Properties, retmsg.PropertiesCount, args);
}
+ internal MethodResponse(IMethodCallMessage msg,
+ Object handlerObject,
+ BinaryMethodReturnMessage smuggledMrm)
+ {
+ if (msg != null)
+ {
+ _methodBase = (MethodBase)msg.MethodBase;
+// _methodCache = InternalRemotingServices.GetReflectionCachedData(MI);
+
+ _methodName = msg.MethodName;
+ _uri = msg.Uri;
+// _typeName = msg.TypeName;
+
+// if (_methodCache.IsOverloaded())
+// _methodSignature = (Type[])msg.MethodSignature;
+
+// argCount = _methodCache.Parameters.Length;
+
+ }
+
+ _returnValue = smuggledMrm.ReturnValue;
+ _outArgs = smuggledMrm.Args;
+ _exception = smuggledMrm.Exception;
+
+ _callContext = smuggledMrm.LogicalCallContext;
+
+ if (smuggledMrm.HasProperties)
+ smuggledMrm.PopulateMessageProperties(Properties);
+ }
+
internal MethodResponse (SerializationInfo info, StreamingContext context)
{
foreach (SerializationEntry entry in info)
set { _targetIdentity = value; }
}
+ bool IInternalMessage.HasProperties()
+ {
+ return (ExternalProperties != null) || (InternalProperties != null);
+ }
+
}
}
Identity identity;
+ internal static String CallContextKey = "__CallContext";
+ internal static String UriKey = "__Uri";
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern void InitMessage (MonoMethod method, object [] out_args);
set { identity = value; }
}
+ bool IInternalMessage.HasProperties()
+ {
+ return properties != null;
+ }
+
public bool IsAsync
{
get { return asyncResult != null; }
set { _targetIdentity = value; }
}
+ bool IInternalMessage.HasProperties ()
+ {
+ return _properties != null;
+ }
+
+ internal bool HasProperties ()
+ {
+ return _properties != null;
+ }
}
}
return _serverType;
}
}
+
+ internal void SetDomainID (int id)
+ {
+ }
}
}
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static bool IsTransparentProxy (object proxy);
+
+ internal static bool ProxyCheckCast (RealProxy rp, RuntimeType castType)
+ {
+ throw new NotImplementedException ("ProxyCheckCast");
+ }
#endif
internal static IMethodReturnMessage InternalExecuteMessage (
+++ /dev/null
-/binary_serialization_format.htm -crlf
+++ /dev/null
-// BinaryCommon.cs
-//
-// Author:
-// Lluis Sanchez Gual (lluis@ideary.com)
-//
-// (C) 2003 Lluis Sanchez Gual
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-namespace System.Runtime.Serialization.Formatters.Binary
-{
- internal class BinaryCommon
- {
- // Header present in all binary serializations
- public static byte[] BinaryHeader = new Byte[] {0,1,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0};
-
- static Type[] _typeCodesToType;
- static byte[] _typeCodeMap;
- public static bool UseReflectionSerialization = false;
-
- static BinaryCommon()
- {
- _typeCodesToType = new Type [19];
- _typeCodesToType[(int)BinaryTypeCode.Boolean] = typeof (Boolean);
- _typeCodesToType[(int)BinaryTypeCode.Byte] = typeof (Byte);
- _typeCodesToType[(int)BinaryTypeCode.Char] = typeof (Char);
- _typeCodesToType[(int)BinaryTypeCode.TimeSpan] = typeof (TimeSpan);
- _typeCodesToType[(int)BinaryTypeCode.DateTime] = typeof (DateTime);
- _typeCodesToType[(int)BinaryTypeCode.Decimal] = typeof (Decimal);
- _typeCodesToType[(int)BinaryTypeCode.Double] = typeof (Double);
- _typeCodesToType[(int)BinaryTypeCode.Int16] = typeof (Int16);
- _typeCodesToType[(int)BinaryTypeCode.Int32] = typeof (Int32);
- _typeCodesToType[(int)BinaryTypeCode.Int64] = typeof (Int64);
- _typeCodesToType[(int)BinaryTypeCode.SByte] = typeof (SByte);
- _typeCodesToType[(int)BinaryTypeCode.Single] = typeof (Single);
- _typeCodesToType[(int)BinaryTypeCode.UInt16] = typeof (UInt16);
- _typeCodesToType[(int)BinaryTypeCode.UInt32] = typeof (UInt32);
- _typeCodesToType[(int)BinaryTypeCode.UInt64] = typeof (UInt64);
- _typeCodesToType[(int)BinaryTypeCode.Null] = null;
- _typeCodesToType[(int)BinaryTypeCode.String] = typeof (string);
-
- _typeCodeMap = new byte[30];
- _typeCodeMap[(int)TypeCode.Boolean] = (byte) BinaryTypeCode.Boolean;
- _typeCodeMap[(int)TypeCode.Byte] = (byte) BinaryTypeCode.Byte;
- _typeCodeMap[(int)TypeCode.Char] = (byte) BinaryTypeCode.Char;
- _typeCodeMap[(int)TypeCode.DateTime] = (byte) BinaryTypeCode.DateTime;
- _typeCodeMap[(int)TypeCode.Decimal] = (byte) BinaryTypeCode.Decimal;
- _typeCodeMap[(int)TypeCode.Double] = (byte) BinaryTypeCode.Double;
- _typeCodeMap[(int)TypeCode.Int16] = (byte) BinaryTypeCode.Int16;
- _typeCodeMap[(int)TypeCode.Int32] = (byte) BinaryTypeCode.Int32;
- _typeCodeMap[(int)TypeCode.Int64] = (byte) BinaryTypeCode.Int64;
- _typeCodeMap[(int)TypeCode.SByte] = (byte) BinaryTypeCode.SByte;
- _typeCodeMap[(int)TypeCode.Single] = (byte) BinaryTypeCode.Single;
- _typeCodeMap[(int)TypeCode.UInt16] = (byte) BinaryTypeCode.UInt16;
- _typeCodeMap[(int)TypeCode.UInt32] = (byte) BinaryTypeCode.UInt32;
- _typeCodeMap[(int)TypeCode.UInt64] = (byte) BinaryTypeCode.UInt64;
- _typeCodeMap[(int)TypeCode.String] = (byte) BinaryTypeCode.String;
-
- // TimeStamp does not have a TypeCode, so it is managed as a special
- // case in GetTypeCode()
- // This environment variable is only for test and benchmarking purposes.
- // By default, mono will always use IL generated class serializers.
- string s = Environment.GetEnvironmentVariable("MONO_REFLECTION_SERIALIZER");
- if (s == null) s = "no";
- UseReflectionSerialization = (s != "no");
- }
-
- public static bool IsPrimitive (Type type)
- {
- return (type.IsPrimitive && type != typeof (IntPtr)) ||
- type == typeof (DateTime) ||
- type == typeof (TimeSpan) ||
- type == typeof (Decimal);
- }
-
- public static byte GetTypeCode (Type type)
- {
- if (type == typeof(TimeSpan)) return (byte) BinaryTypeCode.TimeSpan;
- else return _typeCodeMap [(int)Type.GetTypeCode(type)];
- }
-
- public static Type GetTypeFromCode (int code)
- {
- return _typeCodesToType [code];
- }
-
- public static void CheckSerializable (Type type, ISurrogateSelector selector, StreamingContext context)
- {
- if (!type.IsSerializable && !type.IsInterface)
- {
- if (selector != null && selector.GetSurrogate (type, context, out selector) != null)
- return;
-
- throw new SerializationException ("Type " + type + " is not marked as Serializable.");
- }
- }
-
- public static void SwapBytes (byte[] byteArray, int size, int dataSize)
- {
- byte b;
- if (dataSize == 8) {
- for (int n=0; n<size; n+=8) {
- b = byteArray [n]; byteArray [n] = byteArray [n + 7]; byteArray [n + 7] = b;
- b = byteArray [n+1]; byteArray [n+1] = byteArray [n + 6]; byteArray [n + 6] = b;
- b = byteArray [n+2]; byteArray [n+2] = byteArray [n + 5]; byteArray [n + 5] = b;
- b = byteArray [n+3]; byteArray [n+3] = byteArray [n + 4]; byteArray [n + 4] = b;
- }
- } else if (dataSize == 4) {
- for (int n=0; n<size; n+=4) {
- b = byteArray [n]; byteArray [n] = byteArray [n + 3]; byteArray [n + 3] = b;
- b = byteArray [n+1]; byteArray [n+1] = byteArray [n + 2]; byteArray [n + 2] = b;
- }
- } else if (dataSize == 2) {
- for (int n=0; n<size; n+=2) {
- b = byteArray [n]; byteArray [n] = byteArray [n + 1]; byteArray [n + 1] = b;
- }
- }
- }
- }
-
- internal enum BinaryElement : byte
- {
- Header = 0,
- RefTypeObject = 1,
- UntypedRuntimeObject = 2,
- UntypedExternalObject = 3,
- RuntimeObject = 4,
- ExternalObject = 5,
- String = 6,
- GenericArray = 7,
- BoxedPrimitiveTypeValue = 8,
- ObjectReference = 9,
- NullValue = 10,
- End = 11,
- Assembly = 12,
- ArrayFiller8b = 13,
- ArrayFiller32b = 14,
- ArrayOfPrimitiveType = 15,
- ArrayOfObject = 16,
- ArrayOfString = 17,
- Method = 18,
- _Unknown4 = 19,
- _Unknown5 = 20,
- MethodCall = 21,
- MethodResponse = 22
- }
-
- internal enum TypeTag : byte
- {
- PrimitiveType = 0,
- String = 1,
- ObjectType = 2,
- RuntimeType = 3,
- GenericType = 4,
- ArrayOfObject = 5,
- ArrayOfString = 6,
- ArrayOfPrimitiveType = 7
- }
-
- internal enum ArrayStructure : byte
- {
- SingleDimensional = 0,
- Jagged = 1,
- MultiDimensional = 2
- }
-
- internal enum MethodFlags
- {
- NoArguments = 1,
- PrimitiveArguments = 2,
- ArgumentsInSimpleArray = 4,
- ArgumentsInMultiArray = 8,
- ExcludeLogicalCallContext = 16,
- IncludesLogicalCallContext = 64,
- IncludesSignature = 128,
-
- FormatMask = 15,
-
- GenericArguments = 0x8000,
- NeedsInfoArrayMask = 4 + 8 + 64 + 128 + 0x8000,
- }
-
- internal enum ReturnTypeTag : byte
- {
- Null = 2,
- PrimitiveType = 8,
- ObjectType = 16,
- Exception = 32
- }
-
- enum BinaryTypeCode : byte
- {
- Boolean = 1,
- Byte = 2,
- Char = 3,
- Decimal = 5,
- Double = 6,
- Int16 = 7,
- Int32 = 8,
- Int64 = 9,
- SByte = 10,
- Single = 11,
- TimeSpan = 12,
- DateTime = 13,
- UInt16 = 14,
- UInt32 = 15,
- UInt64 = 16,
- Null = 17,
- String = 18
- }
-
-}
+++ /dev/null
-// BinaryFormatter.cs
-//
-// Author:
-// Dick Porter (dick@ximian.com)
-// Lluis Sanchez Gual (lluis@ideary.com)
-//
-// (C) 2002 Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Collections;
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Runtime.Remoting.Messaging;
-using System.Security.Permissions;
-
-namespace System.Runtime.Serialization.Formatters.Binary {
-
- [ComVisible (true)]
- public sealed class BinaryFormatter :
-#if !FULL_AOT_RUNTIME
- IRemotingFormatter,
-#endif
- IFormatter
- {
- private FormatterAssemblyStyle assembly_format = FormatterAssemblyStyle.Simple;
- private SerializationBinder binder;
- private StreamingContext context;
- private ISurrogateSelector surrogate_selector;
- private FormatterTypeStyle type_format = FormatterTypeStyle.TypesAlways;
- private TypeFilterLevel filter_level = TypeFilterLevel.Full;
-
- public BinaryFormatter()
- {
- surrogate_selector=DefaultSurrogateSelector;
- context=new StreamingContext(StreamingContextStates.All);
- }
-
- public BinaryFormatter(ISurrogateSelector selector, StreamingContext context)
- {
- surrogate_selector=selector;
- this.context=context;
- }
-
-
- // Deserializing objects of type Dictionary<,> List<> and friends does not work in a CoreCLR sandbox, because
- // the default deserialization code uses reflection to do its job, and the fields being reflected on live in mscorlib.dll.
- // DefaultSurrogateSelector enables embedders to provide an alternative method of deserializing specific types in a way
- // that does not violate the CoreCLR rules. See https://gist.github.com/878267 for some actual code that provides CoreCLR safe
- // deserialization code for List<> and Dictionary<,>.
- // DefaultSurrogateSelector is private, and needs to be set by the embedder trough reflection, so we do not expose any public
- // API point that is not present in .NET
- static ISurrogateSelector DefaultSurrogateSelector { get; set; }
-
- public FormatterAssemblyStyle AssemblyFormat
- {
- get {
- return(assembly_format);
- }
- set {
- assembly_format=value;
- }
- }
-
- public SerializationBinder Binder
- {
- get {
- return(binder);
- }
- set {
- binder=value;
- }
- }
-
- public StreamingContext Context
- {
- get {
- return(context);
- }
- set {
- context=value;
- }
- }
-
- public ISurrogateSelector SurrogateSelector
- {
- get {
- return(surrogate_selector);
- }
- set {
- surrogate_selector=value;
- }
- }
-
- public FormatterTypeStyle TypeFormat
- {
- get {
- return(type_format);
- }
- set {
- type_format=value;
- }
- }
-
- public TypeFilterLevel FilterLevel
- {
- get { return filter_level; }
- set { filter_level = value; }
- }
-
- [SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
- public object Deserialize (Stream serializationStream)
- {
- return NoCheckDeserialize (serializationStream, null);
- }
-
- [SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
- public object Deserialize (Stream serializationStream, HeaderHandler handler)
- {
- return NoCheckDeserialize (serializationStream, handler);
- }
-
- // shared by Deserialize and UnsafeDeserialize which both involve different security checks
- private object NoCheckDeserialize (Stream serializationStream, HeaderHandler handler)
- {
- if(serializationStream==null)
- {
- throw new ArgumentNullException("serializationStream");
- }
- if(serializationStream.CanSeek &&
- serializationStream.Length==0)
- {
- throw new SerializationException("serializationStream supports seeking, but its length is 0");
- }
-
- BinaryReader reader = new BinaryReader (serializationStream);
-
- bool hasHeader;
- ReadBinaryHeader (reader, out hasHeader);
-
- // Messages are read using a special static method, which does not use ObjectReader
- // if it is not needed. This saves time and memory.
-
- BinaryElement elem = (BinaryElement) reader.Read ();
-
- if (elem == BinaryElement.MethodCall) {
- return MessageFormatter.ReadMethodCall (elem, reader, hasHeader, handler, this);
- }
- else if (elem == BinaryElement.MethodResponse) {
- return MessageFormatter.ReadMethodResponse (elem, reader, hasHeader, handler, null, this);
- }
- else {
- ObjectReader serializer = new ObjectReader (this);
-
- object result;
- Header[] headers;
- serializer.ReadObjectGraph (elem, reader, hasHeader, out result, out headers);
- if (handler != null) handler(headers);
- return result;
- }
- }
-
- [SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
- public object DeserializeMethodResponse (Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage)
- {
- return NoCheckDeserializeMethodResponse (serializationStream, handler, methodCallMessage);
- }
-
- // shared by DeserializeMethodResponse and UnsafeDeserializeMethodResponse which both involve different security checks
- private object NoCheckDeserializeMethodResponse (Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage)
- {
- if(serializationStream==null) {
- throw new ArgumentNullException("serializationStream");
- }
- if(serializationStream.CanSeek &&
- serializationStream.Length==0) {
- throw new SerializationException("serializationStream supports seeking, but its length is 0");
- }
-
- BinaryReader reader = new BinaryReader (serializationStream);
-
- bool hasHeader;
- ReadBinaryHeader (reader, out hasHeader);
- return MessageFormatter.ReadMethodResponse (reader, hasHeader, handler, methodCallMessage, this);
- }
-
- public void Serialize(Stream serializationStream, object graph)
- {
- Serialize (serializationStream, graph, null);
- }
-
- [SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
- public void Serialize(Stream serializationStream, object graph, Header[] headers)
- {
- if(serializationStream==null) {
- throw new ArgumentNullException ("serializationStream");
- }
-
- BinaryWriter writer = new BinaryWriter (serializationStream);
- WriteBinaryHeader (writer, headers!=null);
-
- if (graph is IMethodCallMessage) {
- MessageFormatter.WriteMethodCall (writer, graph, headers, this);
- }
- else if (graph is IMethodReturnMessage) {
- MessageFormatter.WriteMethodResponse (writer, graph, headers, this);
- }
- else {
- ObjectWriter serializer = new ObjectWriter (this);
- serializer.WriteObjectGraph (writer, graph, headers);
- }
- writer.Flush();
- }
-
- // faster version (under CAS) as this requires a LinkDemand versus full Demand (i.e. a stack-walk)
- // shouldn't be called unless the code is intended to be executed at full-trust
- [ComVisible (false)]
- [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
- public object UnsafeDeserialize (Stream serializationStream, HeaderHandler handler)
- {
- return NoCheckDeserialize (serializationStream, handler);
- }
-
- // faster version (under CAS) as this requires a LinkDemand versus full Demand (i.e. a stack-walk)
- // shouldn't be called unless the code is intended to be executed at full-trust
- [ComVisible (false)]
- [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
- public object UnsafeDeserializeMethodResponse (Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage)
- {
- return NoCheckDeserializeMethodResponse (serializationStream, handler, methodCallMessage);
- }
-
- private void WriteBinaryHeader (BinaryWriter writer, bool hasHeaders)
- {
- writer.Write ((byte)BinaryElement.Header);
- writer.Write ((int)1);
- if (hasHeaders) writer.Write ((int)2);
- else writer.Write ((int)-1);
- writer.Write ((int)1);
- writer.Write ((int)0);
- }
-
- private void ReadBinaryHeader (BinaryReader reader, out bool hasHeaders)
- {
- reader.ReadByte();
- reader.ReadInt32();
- int val = reader.ReadInt32();
- hasHeaders = (val==2);
- reader.ReadInt32();
- reader.ReadInt32();
- }
- }
-}
+++ /dev/null
-2010-03-16 Jb Evain <jbevain@novell.com>
-
- * BinaryCommon.cs: use MOONLIGHT symbol to disambiguate
- MonoTouch and Moonlight code.
-
-2010-02-26 Robert Jordan <robertj@gmx.net>
-
- * ObjectReader.cs (ReadType, GetDeserializationType):
- Add throwOnError parameter that specifies whether to throw an
- exception if the type/assembly is not found.
-
- * ObjectReader.cs (ReadTypeMetadata): Ignore unresolvable
- types while reading the type info. Fixes #430583.
-
- * ObjectReader.cs (GetDeserializationType): Rethrow caught
- exceptions as SerializationExceptions.
-
-2009-10-31 Sebastien Pouliot <sebastien@ximian.com>
-
- * BinaryCommon.cs: Disable MONO_REFLECTION_SERIALIZER override
- for Moonlight plugin.
-
-2009-09-30 Gonzalo Paniagua Javier <gonzalo@novell.com>
-
- * BinaryFormatter.cs: NoCheckDeserialize() was using PeekChar() on a
- reader when it should only read 1 byte. Also BinaryReader.PeekChar()
- tries to set the position of hte stream back to where it was before
- the read, which does not work well with broken Stream
- implementations like BZip2InputStream (reports CanSeek is true when
- it really can't seek). Now we do a Read() and then pass the value we
- read on to the next methods.
-
- * MessageFormatter.cs:
- * ObjectReader.cs: added overloads that take a BinaryElement instead
- of reading it from the reader. Only for the methods used in
- NoCheckDeserialize.
-
- Fixes bug #503435.
-
-2009-03-29 Zoltan Varga <vargaz@gmail.com>
-
- * CodeGenerator.cs: Add synchronization as SRE is not thread safe.
-
-2008-09-17 Robert Jordan <robertj@gmx.net>>
-
- * ObjectReader.cs (ReadTypeMetadata): Replace the check for
- ISerializable with something less `reflective'.
- Fixes #421664.
-
-2008-06-27 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
-
- * BinaryFormatter.cs: Fix parameter name
-
-2008-04-26 Jb Evain <jbevain@novell.com>
-
- * CodeGenerator.cs: replace usage of new Type [0] by
- Type.EmptyTypes. Found with Gendarme.
-
-2008-04-02 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
-
- * BinaryFormatter.cs: Fix parameter names
-
-2007-08-25 Robert Jordan <robertj@gmx.net>
-
- * ObjectReader.cs, ObjectWriter.cs, CodeGenerator.cs:
- Use DateTime.From/ToBinary. Fixes #82400.
-
-2007-08-25 Alan McGovern <amcgovern@novell.com>
-
- * ObjectReader.cs, ObjectWriter.cs, CodeGenerator.cs:
- Reverted fix for #82400.
-
-2007-08-25 Robert Jordan <robertj@gmx.net>
-
- * ObjectReader.cs, ObjectWriter.cs, CodeGenerator.cs:
- Use DateTime.From/ToBinary. Fixes #82400.
-
-2007-08-23 Robert Jordan <robertj@gmx.net>
-
- * ObjectReader.cs, ObjectReader.cs: Map between System.MonoType[] and
- MS.NET's System.RuntimeType[].
-
- * ObjectReader.cs (ReadType): When a type couldn't be found, emit
- a more useful exception.
-
-2007-05-03 Dick Porter <dick@ximian.com>
-
- * BinaryFormatter.cs: Update to 2.0 profile
-
-2006-12-25 Robert Jordan <robertj@gmx.net>
-
- * binary_serialization_format.htm: Update the NET_2_0 format.
- * BinaryCommon.cs: MethodFlags is actually an int32. Add NET_2_0 flags.
- * MessageFormatter.cs: Add support for generic method arguments.
- * ObjectWriter.cs, ObjectReader.cs: Map between System.MonoType and
- MS.NET's System.RuntimeType.
-
-2006-12-01 Lluis Sanchez Gual <lluis@novell.com>
-
- * MessageFormatter.cs: Include the logical context in the message when
- throwing an exception. Fixes a compatibility issue with MS.NET.
-
-2006-10-29 Robert Jordan <robertj@gmx.net>
-
- * ObjectWriter.cs, ObjectReader [NET_2_0]:
- Use the SerializationObjectManager.
-
-2006-09-05 Raja R Harinath <rharinath@novell.com>
-
- Fix #79159
- * ObjectWriter.cs (WritePrimitiveTypeArray) [NET_2_0]: Encode the
- 'Kind' of each DateTime.
- * ObjectReader.cs (ReadArrayOfPrimitiveType) [NET_2_0]: Decode the
- 'Kind' of each DateTime.
-
-2005-12-07 Sebastien Pouliot <sebastien@ximian.com>
-
- * BinaryFormatter.cs: Implemented UnsafeDeserialize and
- UnsafeDeserializeMethodResponse methods. Fixes last TODO in this
- namespace (for both 1.1 and 2.0 profiles).
-
-2005-12-07 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectReader.cs: Added null check in GetDeserializationType.
- Patch by Ben Maurer. Fixes bug #69666.
-
-2005-12-01 Sebastien Pouliot <sebastien@ximian.com>
-
- * BinaryFormatter.cs: Added a demand for SerializationFormatter on
- Serialize method (to make some CAS test work correctly).
-
-2005-05-26 Ben Maurer <bmaurer@ximian.com>
-
- * CodeGenerator.cs: Move module creation to cctor to kill double
- checked locking and typeof locking.
-
-2005-05-17 Lluis Sanchez Gual <lluis@ximian.com>
-
- * CodeGenerator.cs: Don't generate debug info here.
-
-2005-05-09 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectWriter.cs:
- * CodeGenerator.cs: No need to add the class for inherited fields,
- since FieldInfo objects returned by the GetSerializableMembers
- method will already include the class name if needed.
-
-2005-03-23 Lluis Sanchez Gual <lluis@ximian.com>
-
- * BinaryCommon.cs: Added helper method for swapping bytes.
- * ObjectReader.cs:
- * ObjectWriter.cs: Implemented serialization of arrays of primitive
- types using Buffer.BlockCopy to create byffers of data that is written/
- read in a single call. It's much faster now.
-
-2005-03-01 Lluis Sanchez Gual <lluis@ximian.com>
-
- * BinaryCommon.cs: Found the meaning of two unknown binary elements.
- * CodeGenerator.cs: Derive generated classes from ClrTypeMetadata
- instead of TypeMetadata. Added writeTypes parameter to WriteTypeData().
- * ObjectWriter.cs: Use type and assembly names as keys for the type and
- assembly caches. This is needed since ISerializable types can provide
- fake type names (which are mapped to real types by a binder on
- deserialization).
- Implemented support for BinaryFormatter.TypeFormat.
- * BinaryFormatter.cs, MessageFormatter.cs: Implemented support for
- TypeFormat property.
- * ObjectReader.cs: Added support for objects serialized without
- member type information. This fixes bug #73114.
- If a binder return null, use the default way of loading the type.
-
-2005-02-25 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectReader.cs: In ReadArrayOfPrimitiveType, added a specific
- read loop for each type. It's much faster and avoids value boxings.
-
-2005-01-10 Lluis Sanchez Gual <lluis@ximian.com>
-
- * BinaryCommon.cs: IntPtr is not a primitive type in the serialization
- world. This fixes bug #70757.
-
-2004-12-15 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectReader.cs: Use GetField instead of GetMembers. Properties can't
- be serialized, so it makes no sense to use GetMembers.
-
-2004-12-08 Zoltan Varga <vargaz@freemail.hu>
-
- * CodeGenerator.cs: Call new DefineInternalDynamicAssembly method to prevent a race
- condition in the setting of the CorlibInternal flag.
-
-2004-12-06 Zoltan Varga <vargaz@freemail.hu>
-
- * CodeGenerator.cs: Mark the created assembly builder as internal.
-
-2004-11-29 Lluis Sanchez Gual <lluis@ximian.com>
-
- * CodeGenerator.cs: Addded EnumToUnderlying method to get the underlying
- type of an enum. This fixes bug #69753.
-
-2004-07-02 Lluis Sanchez Gual <lluis@ximian.com>
-
- * BinaryCommon.cs: Added CheckSerializable method.
- * ObjectWriter.cs: Check for type serializability even for members with
- null values.
-
-2004-05-29 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
- * ObjectWriter.cs: reduce contention in GetObjectData.
-
-2004-05-14 Vladimir Vukicevic <vladimir@pobox.com>
-
- * binary_serialization_format.htm: renamed filename from having
- spaces to _'s (checked with lluis)
-
-2004-05-13 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectWriter.cs: Fixed and Simplified WriteGenericArray and
- WriteSingleDimensionArrayElements. This also fixes bug #58345.
-
-2004-05-03 Lluis Sanchez Gual <lluis@ximian.com>
-
- * MessageFormatter.cs: In the all-are-primitive case, serialize Args,
- not OutArgs.
-
-2004-04-28 Lluis Sanchez Gual <lluis@ximian.com>
-
- * MessageFormatter.cs: Serialize Args, not OutArgs, like in MS.NET.
-
-2004-04-26 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectReader.cs, ObjectWriter.cs: FIXME cleaning.
-
-2004-04-20 Lluis Sanchez Gual <lluis@ximian.com>
-
- * CodeGenerator.cs, ObjectReader.cs, ObjectWriter.cs: Serialize decimals
- as strings, like in MS.NET. This fixes bug #57186.
-
-2004-02-23 Lluis Sanchez Gual <lluis@ximian.com>
-
- * BinaryCommon.cs: Added UseReflectionSerialization property.
- * CodeGenerator.cs, ObjectWriter.cs: When serializing the name of an
- inherited field, prefix the name with the class name. This fixes #54439.
- Moved check for reflection serialization variable to BinaryCommon.
-
-2004-02-17 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectWriter.cs: Factorized some serialization code in new classes, so it
- is now possible to use fast IL generated classes that use direct access
- to class fields instead of using reflection.
- * CodeGenerator.cs: New file. Has several methods used by ObjectWriter to
- generate serialization code.
-
-2004-02-05 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectWriter.cs: Get the assembly of a member from the member's type, not
- from the type of the value, because that is the type written in the
- metadata section of the object.
-
-2003-12-23 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectReader.cs: Field names can include the type name if the field
- belongs to a base type. Take this into account.
-
-2003-11-26 Lluis Sanchez Gual <lluis@ximian.com>
-
- * BinaryFormatter.cs: Added missing methods.
-
-2003-11-20 Lluis Sanchez Gual <lluis@ximian.com>
-
- * BinaryFormatter.cs, MessageFormatter.cs, ObjectReader.cs: Added support
- for TypeFilter property.
-
-2003-11-16 Lluis Sanchez Gual <lluis@ximian.com>
-
- * BinaryFormatter.cs, MessageFormatter.cs, ObjectWriter.cs:
- Implemented support for AssemblyFormat property.
-
-2003-11-12 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectReader.cs, ObjectWriter.cs: Changed some GetType calls to "is" checks.
-
-2003-07-28 Duncan Mak <duncan@ximian.com>
-
- * BinaryFormatter.cs (WriteBinaryHeader): changed from public to
- private.
-
-2003-07-25 Lluis Sanchez Gual <lluis@ximian.com>
-
- * MessageFormatter.cs: WriteMethodCall(): It must write all parameters,
- including ref and out.
-
-2003-07-24 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectReader.cs, ObjectWriter.cs, BinaryCommon.cs: Fixed bug #45970.
-
-2003-07-17 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectReader.cs: Keep MemberInfo members in type's metadata object, so it is
- not necessary to query them for every object.
- * ObjectWriter.cs: If the value being serialized is a value type (not boxed)
- then there is no need to register it in the ObjectIDGenerator, because it is
- not possible to have two references to the same value type object.
-
-2003-05-13 Lluis Sanchez Gual <lluis@ideary.com>
-
- * ObjectReader.cs: Changed signature of ReadObjectGraph, so now it returns the
- deserialized object and the headers.
- * MessageFormatter.cs: The result of the call to the HeaderHandler delegate is
- now interpreted as the uri of the target object. This seems to be MS.NET
- behavior.
- * BinaryFormatter.cs: Deserialize now calls the HeaderHandler delegate,
- if provided.
-
-2003-02-25 Lluis Sanchez Gual <lluis@ideary.com>
-
- * BinaryFormatter.cs: Implemented support for binders.
- * MessageFormatter.cs: Implemented support for binders.
- * ObjectReader.cs: Implemented support for binders.
-
-2003-02-04 Lluis Sanchez Gual <lluis@ideary.com>
-
- * MessageFormatter.cs: Fixed bug in serialization of arguments.
- * ObjectReader.cs: Fixed bug causing array of structs to fail.
-
-2003-02-11 Patrik Torstensson
-
- * ObjectReader.cs: Fixed root object bug causing object reader to return root object
- before fixup. Closes bug #37842.
-
-2003-02-04 Lluis Sanchez Gual <lluis@ideary.com>
-
- * MessageFormatter.cs: Corrected some bugs that affected serialization of exceptions
-
-2003-02-04 Lluis Sanchez Gual <lluis@ideary.com>
-
- * MessageFormatter.cs: Implemented serialization of message properties.
-
-2003-01-24 Martin Baulig <martin@ximian.com>
-
- * ObjectReader.cs (ReadNextObject): Call
- RaiseDeserializationEvent() on the ObjectManager when we're done
- reading the whole graph.
-
-2003-01-24 Lluis Sanchez Gual <lluis@ideary.com>
-
- * ObjectWriter.cs, ObjectReader.cs: Added suport for headers.
- Corrected encoding of primitive types. Corrected a bug about zero-length arrays.
- * MessageFormatter.cs: Added. Implements serialization of messages.
- * BinaryFormatter.cs: Added serialization of messages.
- * BinaryCommon.cs: Added enum of codes of primitive types.
-
-2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
- * ObjectWriter.cs: make the exception message more useful.
-
-2003-01-16 Lluis Sanchez Gual <lluis@ideary.com>
-
- * BinaryFormatter.cs: implemented Serialize and Deserialize methods.
- * ObjectReader.cs: added.
- * ObjectWriter.cs: added.
- * BinaryCommon.cs. added.
-
-2002-08-22 Nick Drochak <ndrochak@gol.com>
-
- * BinaryArrayTypeEnum.cs: Removed Non-existent enum (must have been
- from beta days)
-
-2002-08-18 Dick Porter <dick@ximian.com>
-
- * BinaryFormatter.cs: Stubbed out
+++ /dev/null
-// CodeGenerator.cs
-//
-// Author:
-// Lluis Sanchez Gual (lluis@ximian.com)
-//
-// (C) 2004 Novell, Inc
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#if !FULL_AOT_RUNTIME
-using System;
-using System.IO;
-using System.Collections;
-using System.Runtime.Serialization;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Globalization;
-
-namespace System.Runtime.Serialization.Formatters.Binary
-{
- internal class CodeGenerator
- {
- // Code generation
-
- static object monitor = new object ();
-
- static ModuleBuilder _module;
-
- static CodeGenerator ()
- {
- AppDomain myDomain = System.Threading.Thread.GetDomain();
- AssemblyName myAsmName = new AssemblyName();
- myAsmName.Name = "__MetadataTypes";
-
- AssemblyBuilder myAsmBuilder = myDomain.DefineInternalDynamicAssembly (myAsmName, AssemblyBuilderAccess.Run);
- _module = myAsmBuilder.DefineDynamicModule("__MetadataTypesModule", false);
- }
-
- static public Type GenerateMetadataType (Type type, StreamingContext context) {
- /* SRE is not thread safe */
- lock (monitor) {
- return GenerateMetadataTypeInternal (type, context);
- }
- }
-
- static public Type GenerateMetadataTypeInternal (Type type, StreamingContext context)
- {
- string name = type.Name + "__TypeMetadata";
- string sufix = "";
- int n = 0;
- while (_module.GetType (name + sufix) != null)
- sufix = (++n).ToString();
-
- name += sufix;
-
- MemberInfo[] members = FormatterServices.GetSerializableMembers (type, context);
-
- TypeBuilder typeBuilder = _module.DefineType (name, TypeAttributes.Public, typeof(ClrTypeMetadata));
-
- Type[] parameters;
- MethodBuilder method;
- ILGenerator gen;
-
- // *********************
- // METHOD public constructor (Type t): base (t);
-
- parameters = Type.EmptyTypes;
-
- ConstructorBuilder ctor = typeBuilder.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, parameters);
- ConstructorInfo baseCtor = typeof(ClrTypeMetadata).GetConstructor (new Type[] { typeof(Type) });
- gen = ctor.GetILGenerator();
-
- gen.Emit (OpCodes.Ldarg_0);
- gen.Emit (OpCodes.Ldtoken, type);
- gen.EmitCall (OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle"), null);
- gen.Emit (OpCodes.Call, baseCtor);
- gen.Emit (OpCodes.Ret);
-
- // *********************
- // METHOD public override void WriteAssemblies (ObjectWriter ow, BinaryWriter writer);
-
- parameters = new Type[] { typeof(ObjectWriter), typeof(BinaryWriter) };
- method = typeBuilder.DefineMethod ("WriteAssemblies", MethodAttributes.Public | MethodAttributes.Virtual, typeof(void), parameters);
- gen = method.GetILGenerator();
-
- foreach (FieldInfo field in members)
- {
- Type memberType = field.FieldType;
- while (memberType.IsArray)
- memberType = memberType.GetElementType();
-
- if (memberType.Assembly != ObjectWriter.CorlibAssembly)
- {
- // EMIT ow.WriteAssembly (writer, memberType.Assembly);
- gen.Emit (OpCodes.Ldarg_1);
- gen.Emit (OpCodes.Ldarg_2);
- EmitLoadTypeAssembly (gen, memberType, field.Name);
- gen.EmitCall (OpCodes.Callvirt, typeof(ObjectWriter).GetMethod("WriteAssembly"), null);
- gen.Emit (OpCodes.Pop);
- }
- }
- gen.Emit(OpCodes.Ret);
- typeBuilder.DefineMethodOverride (method, typeof(TypeMetadata).GetMethod ("WriteAssemblies"));
-
- // *********************
- // METHOD public override void WriteTypeData (ObjectWriter ow, BinaryWriter writer, bool writeTypes);
-
- parameters = new Type[] { typeof(ObjectWriter), typeof(BinaryWriter), typeof(bool) };
- method = typeBuilder.DefineMethod ("WriteTypeData", MethodAttributes.Public | MethodAttributes.Virtual, typeof(void), parameters);
- gen = method.GetILGenerator();
-
- // EMIT writer.Write (members.Length);
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldc_I4, members.Length);
- EmitWrite (gen, typeof(int));
-
- // Names of fields
- foreach (FieldInfo field in members)
- {
- // EMIT writer.Write (name);
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldstr, field.Name);
- EmitWrite (gen, typeof(string));
- }
-
- Label falseLabel = gen.DefineLabel ();
- gen.Emit (OpCodes.Ldarg_3);
- gen.Emit (OpCodes.Brfalse, falseLabel);
-
- // Types of fields
- foreach (FieldInfo field in members)
- {
- // EMIT writer.Write ((byte) ObjectWriter.GetTypeTag (type));
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldc_I4_S, (byte) ObjectWriter.GetTypeTag (field.FieldType));
- EmitWrite (gen, typeof(byte));
- }
-
- // Type specs of fields
- foreach (FieldInfo field in members)
- {
- // EMIT ow.WriteTypeSpec (writer, field.FieldType);
- EmitWriteTypeSpec (gen, field.FieldType, field.Name);
- }
- gen.MarkLabel(falseLabel);
-
- gen.Emit(OpCodes.Ret);
- typeBuilder.DefineMethodOverride (method, typeof(TypeMetadata).GetMethod ("WriteTypeData"));
-
- // *********************
- // METHOD public override void WriteObjectData (ObjectWriter ow, BinaryWriter writer, object data)
-
- parameters = new Type[] { typeof(ObjectWriter), typeof(BinaryWriter), typeof(object) };
- method = typeBuilder.DefineMethod ("WriteObjectData", MethodAttributes.Public | MethodAttributes.Virtual, typeof(void), parameters);
- gen = method.GetILGenerator();
-
- LocalBuilder localBuilder = gen.DeclareLocal (type);
- OpCode lload = OpCodes.Ldloc;
-
- gen.Emit (OpCodes.Ldarg_3);
- if (type.IsValueType)
- {
- gen.Emit (OpCodes.Unbox, type);
- LoadFromPtr (gen, type);
- lload = OpCodes.Ldloca_S;
- }
- else
- gen.Emit (OpCodes.Castclass, type);
-
- gen.Emit (OpCodes.Stloc, localBuilder);
-
- foreach (FieldInfo field in members)
- {
- // EMIT ow.WriteValue (writer, ((FieldInfo)members[n]).FieldType, values[n]);
- Type ftype = field.FieldType;
- if (BinaryCommon.IsPrimitive (ftype))
- {
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (lload, localBuilder);
- if (ftype == typeof(DateTime) || ftype == typeof(TimeSpan) || ftype == typeof(decimal))
- gen.Emit (OpCodes.Ldflda, field);
- else
- gen.Emit (OpCodes.Ldfld, field);
- EmitWritePrimitiveValue (gen, ftype);
- }
- else
- {
- gen.Emit (OpCodes.Ldarg_1);
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldtoken, ftype);
- gen.EmitCall (OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle"), null);
- gen.Emit (lload, localBuilder);
- gen.Emit (OpCodes.Ldfld, field);
- if (ftype.IsValueType)
- gen.Emit (OpCodes.Box, ftype);
- gen.EmitCall (OpCodes.Call, typeof(ObjectWriter).GetMethod("WriteValue"), null);
- }
- }
-
- gen.Emit(OpCodes.Ret);
- typeBuilder.DefineMethodOverride (method, typeof(TypeMetadata).GetMethod ("WriteObjectData"));
-
- return typeBuilder.CreateType();
- }
-
- public static void LoadFromPtr (ILGenerator ig, Type t)
- {
- if (t == typeof(int))
- ig.Emit (OpCodes.Ldind_I4);
- else if (t == typeof(uint))
- ig.Emit (OpCodes.Ldind_U4);
- else if (t == typeof(short))
- ig.Emit (OpCodes.Ldind_I2);
- else if (t == typeof(ushort))
- ig.Emit (OpCodes.Ldind_U2);
- else if (t == typeof(char))
- ig.Emit (OpCodes.Ldind_U2);
- else if (t == typeof(byte))
- ig.Emit (OpCodes.Ldind_U1);
- else if (t == typeof(sbyte))
- ig.Emit (OpCodes.Ldind_I1);
- else if (t == typeof(ulong))
- ig.Emit (OpCodes.Ldind_I8);
- else if (t == typeof(long))
- ig.Emit (OpCodes.Ldind_I8);
- else if (t == typeof(float))
- ig.Emit (OpCodes.Ldind_R4);
- else if (t == typeof(double))
- ig.Emit (OpCodes.Ldind_R8);
- else if (t == typeof(bool))
- ig.Emit (OpCodes.Ldind_I1);
- else if (t == typeof(IntPtr))
- ig.Emit (OpCodes.Ldind_I);
- else if (t.IsEnum) {
- if (t == typeof(Enum))
- ig.Emit (OpCodes.Ldind_Ref);
- else
- LoadFromPtr (ig, EnumToUnderlying (t));
- } else if (t.IsValueType)
- ig.Emit (OpCodes.Ldobj, t);
- else
- ig.Emit (OpCodes.Ldind_Ref);
- }
-
- static void EmitWriteTypeSpec (ILGenerator gen, Type type, string member)
- {
- // WARNING Keep in sync with WriteTypeSpec
-
- switch (ObjectWriter.GetTypeTag (type))
- {
- case TypeTag.PrimitiveType:
- // EMIT writer.Write (BinaryCommon.GetTypeCode (type));
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldc_I4_S, (byte) BinaryCommon.GetTypeCode (type));
- EmitWrite (gen, typeof(byte));
- break;
-
- case TypeTag.RuntimeType:
- // EMIT writer.Write (type.FullName);
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldstr, type.FullName);
- EmitWrite (gen, typeof(string));
- break;
-
- case TypeTag.GenericType:
- // EMIT writer.Write (type.FullName);
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldstr, type.FullName);
- EmitWrite (gen, typeof(string));
-
- // EMIT writer.Write ((int)ow.GetAssemblyId (type.Assembly));
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldarg_1);
- EmitLoadTypeAssembly (gen, type, member);
- gen.EmitCall (OpCodes.Callvirt, typeof(ObjectWriter).GetMethod("GetAssemblyId"), null);
- gen.Emit (OpCodes.Conv_I4);
- EmitWrite (gen, typeof(int));
- break;
-
- case TypeTag.ArrayOfPrimitiveType:
- // EMIT writer.Write (BinaryCommon.GetTypeCode (type.GetElementType()));
- gen.Emit (OpCodes.Ldarg_2);
- gen.Emit (OpCodes.Ldc_I4_S, (byte) BinaryCommon.GetTypeCode (type.GetElementType()));
- EmitWrite (gen, typeof(byte));
- break;
-
- default:
- // Type spec not needed
- break;
- }
- }
-
- static void EmitLoadTypeAssembly (ILGenerator gen, Type type, string member)
- {
- gen.Emit (OpCodes.Ldtoken, type);
- gen.EmitCall (OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle"), null);
- gen.EmitCall (OpCodes.Callvirt, typeof(Type).GetProperty("Assembly").GetGetMethod(), null);
- }
-
- static void EmitWrite (ILGenerator gen, Type type)
- {
- gen.EmitCall (OpCodes.Callvirt, typeof(BinaryWriter).GetMethod("Write", new Type[] { type }), null);
- }
-
- public static void EmitWritePrimitiveValue (ILGenerator gen, Type type)
- {
- switch (Type.GetTypeCode (type))
- {
- case TypeCode.Boolean:
- case TypeCode.Byte:
- case TypeCode.Char:
- case TypeCode.Double:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.SByte:
- case TypeCode.Single:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- case TypeCode.String:
- EmitWrite (gen, type);
- break;
-
- case TypeCode.Decimal:
- // writer.Write (val.ToString (CultureInfo.InvariantCulture));
- gen.EmitCall (OpCodes.Call, typeof(CultureInfo).GetProperty("InvariantCulture").GetGetMethod(), null);
- gen.EmitCall (OpCodes.Call, typeof(Decimal).GetMethod("ToString", new Type[] {typeof(IFormatProvider)}), null);
- EmitWrite (gen, typeof(string));
- break;
-
- case TypeCode.DateTime:
- gen.EmitCall (OpCodes.Call, typeof(DateTime).GetMethod("ToBinary", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance), null);
- EmitWrite (gen, typeof(long));
- break;
-
- default:
- if (type == typeof (TimeSpan)) {
- gen.EmitCall (OpCodes.Call, typeof(TimeSpan).GetProperty("Ticks").GetGetMethod(), null);
- EmitWrite (gen, typeof(long));
- }
- else
- throw new NotSupportedException ("Unsupported primitive type: " + type.FullName);
- break;
- }
- }
-
- //
- // This is needed, because enumerations from assemblies
- // do not report their underlyingtype, but they report
- // themselves
- //
- public static Type EnumToUnderlying (Type t)
- {
- TypeCode tc = Type.GetTypeCode (t);
-
- switch (tc){
- case TypeCode.Boolean:
- return typeof (bool);
- case TypeCode.Byte:
- return typeof (byte);
- case TypeCode.SByte:
- return typeof (sbyte);
- case TypeCode.Char:
- return typeof (char);
- case TypeCode.Int16:
- return typeof (short);
- case TypeCode.UInt16:
- return typeof (ushort);
- case TypeCode.Int32:
- return typeof (int);
- case TypeCode.UInt32:
- return typeof (uint);
- case TypeCode.Int64:
- return typeof (long);
- case TypeCode.UInt64:
- return typeof (ulong);
- }
- throw new Exception ("Unhandled typecode in enum " + tc + " from " + t.AssemblyQualifiedName);
- }
- }
- }
-
-#endif
+++ /dev/null
-//
-// System.Runtime.Remoting.MessageFormatter.cs
-//
-// Author: Lluis Sanchez Gual (lluis@ideary.com)
-//
-// (C) 2003, Lluis Sanchez Gual
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using System.Reflection;
-using System.Collections;
-using System.Runtime.Remoting;
-using System.Runtime.Serialization;
-using System.Runtime.Remoting.Messaging;
-
-namespace System.Runtime.Serialization.Formatters.Binary
-{
- internal class MessageFormatter
- {
- public static void WriteMethodCall (BinaryWriter writer, object obj, Header[] headers, BinaryFormatter formatter)
- {
- IMethodCallMessage call = (IMethodCallMessage)obj;
- writer.Write ((byte) BinaryElement.MethodCall);
-
- MethodFlags methodFlags;
- int infoArraySize = 0;
- object info = null;
- object[] extraProperties = null;
-
- if (call.LogicalCallContext != null && call.LogicalCallContext.HasInfo)
- {
- methodFlags = MethodFlags.IncludesLogicalCallContext;
- infoArraySize++;
- }
- else
- methodFlags = MethodFlags.ExcludeLogicalCallContext;
-
- if (RemotingServices.IsMethodOverloaded (call))
- {
- infoArraySize++;
- methodFlags |= MethodFlags.IncludesSignature;
- }
-
- if (call.Properties.Count > MethodCallDictionary.InternalKeys.Length)
- {
- extraProperties = GetExtraProperties (call.Properties, MethodCallDictionary.InternalKeys);
- infoArraySize++;
- }
-
- if (call.MethodBase.IsGenericMethod) {
- infoArraySize++;
- methodFlags |= MethodFlags.GenericArguments;
- }
- if (call.ArgCount == 0)
- methodFlags |= MethodFlags.NoArguments;
- else {
- if (AllTypesArePrimitive (call.Args))
- methodFlags |= MethodFlags.PrimitiveArguments;
- else {
- if (infoArraySize == 0)
- methodFlags |= MethodFlags.ArgumentsInSimpleArray;
- else {
- methodFlags |= MethodFlags.ArgumentsInMultiArray;
- infoArraySize++;
- }
- }
- }
-
- writer.Write ((int) methodFlags);
-
- // Method name
- writer.Write ((byte) BinaryTypeCode.String);
- writer.Write (call.MethodName);
-
- // Class name
- writer.Write ((byte) BinaryTypeCode.String);
- writer.Write (call.TypeName);
-
- // Arguments
-
- if ((methodFlags & MethodFlags.PrimitiveArguments) > 0)
- {
- writer.Write ((uint)call.Args.Length);
- for (int n=0; n<call.ArgCount; n++)
- {
- object arg = call.GetArg(n);
- if (arg != null) {
- writer.Write (BinaryCommon.GetTypeCode (arg.GetType()));
- ObjectWriter.WritePrimitiveValue (writer, arg);
- }
- else
- writer.Write ((byte)BinaryTypeCode.Null);
- }
- }
-
- if ( infoArraySize > 0)
- {
- object[] ainfo = new object[infoArraySize];
- int n=0;
- if ((methodFlags & MethodFlags.ArgumentsInMultiArray) > 0) ainfo[n++] = call.Args;
- if ((methodFlags & MethodFlags.GenericArguments) > 0) ainfo[n++] = call.MethodBase.GetGenericArguments ();
- if ((methodFlags & MethodFlags.IncludesSignature) > 0) ainfo[n++] = call.MethodSignature;
- if ((methodFlags & MethodFlags.IncludesLogicalCallContext) > 0) ainfo[n++] = call.LogicalCallContext;
- if (extraProperties != null) ainfo[n++] = extraProperties;
- info = ainfo;
- }
- else if ((methodFlags & MethodFlags.ArgumentsInSimpleArray) > 0)
- info = call.Args;
-
- if (info != null)
- {
- ObjectWriter objectWriter = new ObjectWriter (formatter);
- objectWriter.WriteObjectGraph (writer, info, headers);
- }
- else
- writer.Write ((byte) BinaryElement.End);
- }
-
- public static void WriteMethodResponse (BinaryWriter writer, object obj, Header[] headers, BinaryFormatter formatter)
- {
- IMethodReturnMessage resp = (IMethodReturnMessage)obj;
- writer.Write ((byte) BinaryElement.MethodResponse);
-
- string[] internalProperties = MethodReturnDictionary.InternalReturnKeys;
-
- int infoArrayLength = 0;
- object info = null;
- object[] extraProperties = null;
-
- // Type of return value
-
- ReturnTypeTag returnTypeTag;
- MethodFlags contextFlag = MethodFlags.ExcludeLogicalCallContext;
-
- if (resp.Exception != null) {
- returnTypeTag = ReturnTypeTag.Exception | ReturnTypeTag.Null;
- internalProperties = MethodReturnDictionary.InternalExceptionKeys;
- infoArrayLength = 1;
- }
- else if (resp.ReturnValue == null) {
- returnTypeTag = ReturnTypeTag.Null;
- }
- else if (IsMethodPrimitive(resp.ReturnValue.GetType())) {
- returnTypeTag = ReturnTypeTag.PrimitiveType;
- }
- else {
- returnTypeTag = ReturnTypeTag.ObjectType;
- infoArrayLength++;
- }
-
- // Message flags
-
- MethodFlags formatFlag;
-
- if ((resp.LogicalCallContext != null) && resp.LogicalCallContext.HasInfo)
- {
- contextFlag = MethodFlags.IncludesLogicalCallContext;
- infoArrayLength++;
- }
-
- if (resp.Properties.Count > internalProperties.Length && ((returnTypeTag & ReturnTypeTag.Exception) == 0))
- {
- extraProperties = GetExtraProperties (resp.Properties, internalProperties);
- infoArrayLength++;
- }
-
- if (resp.OutArgCount == 0)
- formatFlag = MethodFlags.NoArguments;
- else
- {
- if (AllTypesArePrimitive (resp.Args))
- formatFlag = MethodFlags.PrimitiveArguments;
- else
- {
- if (infoArrayLength == 0)
- formatFlag = MethodFlags.ArgumentsInSimpleArray;
- else {
- formatFlag = MethodFlags.ArgumentsInMultiArray;
- infoArrayLength++;
- }
- }
- }
-
- writer.Write ((byte) (contextFlag | formatFlag));
- writer.Write ((byte) returnTypeTag);
-
- // FIXME: what are the following 2 bytes for?
- writer.Write ((byte) 0);
- writer.Write ((byte) 0);
-
- // Arguments
-
- if (returnTypeTag == ReturnTypeTag.PrimitiveType)
- {
- writer.Write (BinaryCommon.GetTypeCode (resp.ReturnValue.GetType()));
- ObjectWriter.WritePrimitiveValue (writer, resp.ReturnValue);
- }
-
- if (formatFlag == MethodFlags.PrimitiveArguments)
- {
- writer.Write ((uint)resp.ArgCount);
- for (int n=0; n<resp.ArgCount; n++)
- {
- object val = resp.GetArg(n);
- if (val != null) {
- writer.Write (BinaryCommon.GetTypeCode (val.GetType()));
- ObjectWriter.WritePrimitiveValue (writer, val);
- }
- else
- writer.Write ((byte)BinaryTypeCode.Null);
- }
- }
-
- if (infoArrayLength > 0)
- {
- object[] infoArray = new object[infoArrayLength];
- int n = 0;
-
- if ((returnTypeTag & ReturnTypeTag.Exception) != 0)
- infoArray[n++] = resp.Exception;
-
- if (formatFlag == MethodFlags.ArgumentsInMultiArray)
- infoArray[n++] = resp.Args;
-
- if (returnTypeTag == ReturnTypeTag.ObjectType)
- infoArray[n++] = resp.ReturnValue;
-
- if (contextFlag == MethodFlags.IncludesLogicalCallContext)
- infoArray[n++] = resp.LogicalCallContext;
-
- if (extraProperties != null)
- infoArray[n++] = extraProperties;
-
- info = infoArray;
- }
- else if ((formatFlag & MethodFlags.ArgumentsInSimpleArray) > 0)
- info = resp.Args;
-
- if (info != null)
- {
- ObjectWriter objectWriter = new ObjectWriter (formatter);
- objectWriter.WriteObjectGraph (writer, info, headers);
- }
- else
- writer.Write ((byte) BinaryElement.End);
- }
-
- public static object ReadMethodCall (BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, BinaryFormatter formatter)
- {
- BinaryElement elem = (BinaryElement)reader.ReadByte(); // The element code
- return ReadMethodCall (elem, reader, hasHeaders, headerHandler, formatter);
- }
-
- public static object ReadMethodCall (BinaryElement elem, BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, BinaryFormatter formatter)
- {
- if (elem != BinaryElement.MethodCall) throw new SerializationException("Invalid format. Expected BinaryElement.MethodCall, found " + elem);
-
- MethodFlags flags = (MethodFlags) reader.ReadInt32();
-
- if (((BinaryTypeCode)reader.ReadByte()) != BinaryTypeCode.String) throw new SerializationException ("Invalid format");
- string methodName = reader.ReadString();
-
- if (((BinaryTypeCode)reader.ReadByte()) != BinaryTypeCode.String) throw new SerializationException ("Invalid format");
- string className = reader.ReadString();
-
- //bool hasContextInfo = (flags & MethodFlags.IncludesLogicalCallContext) > 0;
-
- object[] arguments = null;
- object methodSignature = null;
- object callContext = null;
- object[] extraProperties = null;
- Header[] headers = null;
- Type[] genericArguments = null;
-
- if ((flags & MethodFlags.PrimitiveArguments) > 0)
- {
- uint count = reader.ReadUInt32();
- arguments = new object[count];
- for (int n=0; n<count; n++)
- {
- Type type = BinaryCommon.GetTypeFromCode (reader.ReadByte());
- arguments[n] = ObjectReader.ReadPrimitiveTypeValue (reader, type);
- }
- }
-
- if ((flags & MethodFlags.NeedsInfoArrayMask) > 0)
- {
- ObjectReader objectReader = new ObjectReader (formatter);
-
- object result;
- objectReader.ReadObjectGraph (reader, hasHeaders, out result, out headers);
- object[] msgInfo = (object[]) result;
-
- if ((flags & MethodFlags.ArgumentsInSimpleArray) > 0) {
- arguments = msgInfo;
- }
- else
- {
- int n = 0;
- if ((flags & MethodFlags.ArgumentsInMultiArray) > 0) {
- if (msgInfo.Length > 1) arguments = (object[]) msgInfo[n++];
- else arguments = new object[0];
- }
-
- if ((flags & MethodFlags.GenericArguments) > 0)
- genericArguments = (Type[]) msgInfo[n++];
-
- if ((flags & MethodFlags.IncludesSignature) > 0)
- methodSignature = msgInfo[n++];
-
- if ((flags & MethodFlags.IncludesLogicalCallContext) > 0)
- callContext = msgInfo[n++];
-
- if (n < msgInfo.Length)
- extraProperties = (object[]) msgInfo[n];
- }
- }
- else {
- reader.ReadByte (); // Reads the stream ender
- }
-
- if (arguments == null) arguments = new object[0];
-
- string uri = null;
- if (headerHandler != null)
- uri = headerHandler(headers) as string;
-
- Header[] methodInfo = new Header[7];
- methodInfo[0] = new Header("__MethodName", methodName);
- methodInfo[1] = new Header("__MethodSignature", methodSignature);
- methodInfo[2] = new Header("__TypeName", className);
- methodInfo[3] = new Header("__Args", arguments);
- methodInfo[4] = new Header("__CallContext", callContext);
- methodInfo[5] = new Header("__Uri", uri);
- methodInfo[6] = new Header("__GenericArguments", genericArguments);
-
- MethodCall call = new MethodCall (methodInfo);
-
- if (extraProperties != null) {
- foreach (DictionaryEntry entry in extraProperties)
- call.Properties [(string)entry.Key] = entry.Value;
- }
-
- return call;
- }
-
- public static object ReadMethodResponse (BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, IMethodCallMessage methodCallMessage, BinaryFormatter formatter)
- {
- BinaryElement elem = (BinaryElement) reader.ReadByte ();
- return ReadMethodResponse (elem, reader, hasHeaders, headerHandler, methodCallMessage, formatter);
- }
-
- public static object ReadMethodResponse (BinaryElement elem, BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, IMethodCallMessage methodCallMessage, BinaryFormatter formatter)
- {
- if (elem != BinaryElement.MethodResponse) throw new SerializationException("Invalid format. Expected BinaryElement.MethodResponse, found " + elem);
-
- MethodFlags flags = (MethodFlags) reader.ReadByte ();
- ReturnTypeTag typeTag = (ReturnTypeTag) reader.ReadByte ();
- bool hasContextInfo = (flags & MethodFlags.IncludesLogicalCallContext) > 0;
-
- // FIXME: find a meaning for those 2 bytes
- reader.ReadByte();
- reader.ReadByte();
-
- object returnValue = null;
- object[] outArgs = null;
- LogicalCallContext callContext = null;
- Exception exception = null;
- object[] extraProperties = null;
- Header[] headers = null;
-
- if ((typeTag & ReturnTypeTag.PrimitiveType) > 0)
- {
- Type type = BinaryCommon.GetTypeFromCode (reader.ReadByte());
- returnValue = ObjectReader.ReadPrimitiveTypeValue (reader, type);
- }
-
- if ((flags & MethodFlags.PrimitiveArguments) > 0)
- {
- uint count = reader.ReadUInt32();
- outArgs = new object[count];
- for (int n=0; n<count; n++) {
- Type type = BinaryCommon.GetTypeFromCode (reader.ReadByte());
- outArgs[n] = ObjectReader.ReadPrimitiveTypeValue (reader, type);
- }
- }
-
- if (hasContextInfo || (typeTag & ReturnTypeTag.ObjectType) > 0 ||
- (typeTag & ReturnTypeTag.Exception) > 0 ||
- (flags & MethodFlags.ArgumentsInSimpleArray) > 0 ||
- (flags & MethodFlags.ArgumentsInMultiArray) > 0)
- {
- // There objects that need to be deserialized using an ObjectReader
-
- ObjectReader objectReader = new ObjectReader (formatter);
- object result;
- objectReader.ReadObjectGraph (reader, hasHeaders, out result, out headers);
- object[] msgInfo = (object[]) result;
-
- if ((typeTag & ReturnTypeTag.Exception) > 0) {
- exception = (Exception) msgInfo[0];
- if (hasContextInfo) callContext = (LogicalCallContext)msgInfo[1];
- }
- else if ((flags & MethodFlags.NoArguments) > 0 || (flags & MethodFlags.PrimitiveArguments) > 0) {
- int n = 0;
- if ((typeTag & ReturnTypeTag.ObjectType) > 0) returnValue = msgInfo [n++];
- if (hasContextInfo) callContext = (LogicalCallContext)msgInfo[n++];
- if (n < msgInfo.Length) extraProperties = (object[]) msgInfo[n];
- }
- else if ((flags & MethodFlags.ArgumentsInSimpleArray) > 0) {
- outArgs = msgInfo;
- }
- else {
- int n = 0;
- outArgs = (object[]) msgInfo[n++];
- if ((typeTag & ReturnTypeTag.ObjectType) > 0) returnValue = msgInfo[n++];
- if (hasContextInfo) callContext = (LogicalCallContext)msgInfo[n++];
- if (n < msgInfo.Length) extraProperties = (object[]) msgInfo[n];
- }
- }
- else {
- reader.ReadByte (); // Reads the stream ender
- }
-
- if (headerHandler != null)
- headerHandler(headers);
-
- if (exception != null)
- return new ReturnMessage (exception, methodCallMessage);
- else
- {
- int argCount = (outArgs!=null) ? outArgs.Length : 0;
- ReturnMessage result = new ReturnMessage (returnValue, outArgs, argCount, callContext, methodCallMessage);
-
- if (extraProperties != null) {
- foreach (DictionaryEntry entry in extraProperties)
- result.Properties [(string)entry.Key] = entry.Value;
- }
-
- return result;
- }
- }
-
- private static bool AllTypesArePrimitive(object[] objects)
- {
- foreach (object ob in objects)
- {
- if (ob != null && !IsMethodPrimitive(ob.GetType()))
- return false;
- }
- return true;
- }
-
- // When serializing methods, string are considered primitive types
- public static bool IsMethodPrimitive (Type type)
- {
- return type.IsPrimitive || type == typeof(string) || type == typeof (DateTime) || type == typeof (Decimal);
- }
-
- static object[] GetExtraProperties (IDictionary properties, string[] internalKeys)
- {
- object[] extraProperties = new object [properties.Count - internalKeys.Length];
-
- int n = 0;
- IDictionaryEnumerator e = properties.GetEnumerator();
- while (e.MoveNext())
- if (!IsInternalKey ((string) e.Entry.Key, internalKeys)) extraProperties [n++] = e.Entry;
-
- return extraProperties;
- }
-
- static bool IsInternalKey (string key, string[] internalKeys)
- {
- foreach (string ikey in internalKeys)
- if (key == ikey) return true;
- return false;
- }
-
- }
-}
+++ /dev/null
-// ObjectReader.cs
-//
-// Author:
-// Lluis Sanchez Gual (lluis@ideary.com)
-// Patrik Torstensson
-//
-// (C) 2003 Lluis Sanchez Gual
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.Serialization;
-using System.IO;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.Remoting.Messaging;
-using System.Globalization;
-
-namespace System.Runtime.Serialization.Formatters.Binary
-{
- internal class ObjectReader
- {
-// BinaryFormatter _formatter;
- ISurrogateSelector _surrogateSelector;
- StreamingContext _context;
- SerializationBinder _binder;
-
- TypeFilterLevel _filterLevel;
-
- ObjectManager _manager;
- Hashtable _registeredAssemblies = new Hashtable();
- Hashtable _typeMetadataCache = new Hashtable();
-
- object _lastObject = null;
- long _lastObjectID = 0;
- long _rootObjectID = 0;
- byte[] arrayBuffer;
- int ArrayBufferLength = 4096;
-
- class TypeMetadata
- {
- public Type Type;
- public Type[] MemberTypes;
- public string[] MemberNames;
- public MemberInfo[] MemberInfos;
- public int FieldCount;
- public bool NeedsSerializationInfo;
- }
-
- class ArrayNullFiller
- {
- public ArrayNullFiller(int count) { NullCount = count; }
- public int NullCount;
- }
-
- public ObjectReader (BinaryFormatter formatter)
- {
-// _formatter = formatter;
- _surrogateSelector = formatter.SurrogateSelector;
- _context = formatter.Context;
- _binder = formatter.Binder;
- _manager = new ObjectManager (_surrogateSelector, _context);
-
- _filterLevel = formatter.FilterLevel;
- }
-
- public void ReadObjectGraph (BinaryReader reader, bool readHeaders, out object result, out Header[] headers)
- {
- BinaryElement elem = (BinaryElement)reader.ReadByte ();
- ReadObjectGraph (elem, reader, readHeaders, out result, out headers);
- }
-
- public void ReadObjectGraph (BinaryElement elem, BinaryReader reader, bool readHeaders, out object result, out Header[] headers)
- {
- headers = null;
-
- // Reads the objects. The first object in the stream is the
- // root object.
- bool next = ReadNextObject (elem, reader);
- if (next) {
- do {
- if (readHeaders && (headers == null))
- headers = (Header[])CurrentObject;
- else
- if (_rootObjectID == 0) _rootObjectID = _lastObjectID;
- } while (ReadNextObject (reader));
- }
-
- result = _manager.GetObject (_rootObjectID);
- }
-
- bool ReadNextObject (BinaryElement element, BinaryReader reader)
- {
- if (element == BinaryElement.End)
- {
- _manager.DoFixups();
-
- _manager.RaiseDeserializationEvent();
- return false;
- }
-
- SerializationInfo info;
- long objectId;
-
- ReadObject (element, reader, out objectId, out _lastObject, out info);
-
- if (objectId != 0) {
- RegisterObject (objectId, _lastObject, info, 0, null, null);
- _lastObjectID = objectId;
- }
-
- return true;
- }
-
- public bool ReadNextObject (BinaryReader reader)
- {
- BinaryElement element = (BinaryElement)reader.ReadByte ();
- if (element == BinaryElement.End)
- {
- _manager.DoFixups();
-
- _manager.RaiseDeserializationEvent();
- return false;
- }
-
- SerializationInfo info;
- long objectId;
-
- ReadObject (element, reader, out objectId, out _lastObject, out info);
-
- if (objectId != 0) {
- RegisterObject (objectId, _lastObject, info, 0, null, null);
- _lastObjectID = objectId;
- }
-
- return true;
- }
-
- public object CurrentObject
- {
- get { return _lastObject; }
- }
-
- // Reads an object from the stream. The object is registered in the ObjectManager.
- // The result can be either the object instance
- // or the id of the object (when what is found in the stream is an object reference).
- // If an object instance is read, the objectId is set to 0.
-
- private void ReadObject (BinaryElement element, BinaryReader reader, out long objectId, out object value, out SerializationInfo info)
- {
- switch (element)
- {
- case BinaryElement.RefTypeObject:
- ReadRefTypeObjectInstance (reader, out objectId, out value, out info);
- break;
-
- case BinaryElement.UntypedRuntimeObject:
- ReadObjectInstance (reader, true, false, out objectId, out value, out info);
- break;
-
- case BinaryElement.UntypedExternalObject:
- ReadObjectInstance (reader, false, false, out objectId, out value, out info);
- break;
-
- case BinaryElement.RuntimeObject:
- ReadObjectInstance (reader, true, true, out objectId, out value, out info);
- break;
-
- case BinaryElement.ExternalObject:
- ReadObjectInstance (reader, false, true, out objectId, out value, out info);
- break;
-
- case BinaryElement.String:
- info = null;
- ReadStringIntance (reader, out objectId, out value);
- break;
-
- case BinaryElement.GenericArray:
- info = null;
- ReadGenericArray (reader, out objectId, out value);
- break;
-
-
- case BinaryElement.BoxedPrimitiveTypeValue:
- value = ReadBoxedPrimitiveTypeValue (reader);
- objectId = 0;
- info = null;
- break;
-
- case BinaryElement.NullValue:
- value = null;
- objectId = 0;
- info = null;
- break;
-
- case BinaryElement.Assembly:
- ReadAssembly (reader);
- ReadObject ((BinaryElement)reader.ReadByte (), reader, out objectId, out value, out info);
- break;
-
- case BinaryElement.ArrayFiller8b:
- value = new ArrayNullFiller(reader.ReadByte());
- objectId = 0;
- info = null;
- break;
-
- case BinaryElement.ArrayFiller32b:
- value = new ArrayNullFiller(reader.ReadInt32());
- objectId = 0;
- info = null;
- break;
-
- case BinaryElement.ArrayOfPrimitiveType:
- ReadArrayOfPrimitiveType (reader, out objectId, out value);
- info = null;
- break;
-
- case BinaryElement.ArrayOfObject:
- ReadArrayOfObject (reader, out objectId, out value);
- info = null;
- break;
-
- case BinaryElement.ArrayOfString:
- ReadArrayOfString (reader, out objectId, out value);
- info = null;
- break;
-
- default:
- throw new SerializationException ("Unexpected binary element: " + (int)element);
- }
- }
-
- private void ReadAssembly (BinaryReader reader)
- {
- long id = (long) reader.ReadUInt32 ();
- string assemblyName = reader.ReadString ();
- _registeredAssemblies [id] = assemblyName;
- }
-
- private void ReadObjectInstance (BinaryReader reader, bool isRuntimeObject, bool hasTypeInfo, out long objectId, out object value, out SerializationInfo info)
- {
- objectId = (long) reader.ReadUInt32 ();
-
- TypeMetadata metadata = ReadTypeMetadata (reader, isRuntimeObject, hasTypeInfo);
- ReadObjectContent (reader, metadata, objectId, out value, out info);
- }
-
- private void ReadRefTypeObjectInstance (BinaryReader reader, out long objectId, out object value, out SerializationInfo info)
- {
- objectId = (long) reader.ReadUInt32 ();
- long refTypeObjectId = (long) reader.ReadUInt32 ();
-
- // Gets the type of the referred object and its metadata
-
- object refObj = _manager.GetObject (refTypeObjectId);
- if (refObj == null) throw new SerializationException ("Invalid binary format");
- TypeMetadata metadata = (TypeMetadata)_typeMetadataCache [refObj.GetType()];
-
- ReadObjectContent (reader, metadata, objectId, out value, out info);
- }
-
- private void ReadObjectContent (BinaryReader reader, TypeMetadata metadata, long objectId, out object objectInstance, out SerializationInfo info)
- {
- if (_filterLevel == TypeFilterLevel.Low)
- objectInstance = FormatterServices.GetSafeUninitializedObject (metadata.Type);
- else
- objectInstance = FormatterServices.GetUninitializedObject (metadata.Type);
- _manager.RaiseOnDeserializingEvent (objectInstance);
-
- info = metadata.NeedsSerializationInfo ? new SerializationInfo(metadata.Type, new FormatterConverter()) : null;
-
- if (metadata.MemberNames != null) {
- for (int n=0; n<metadata.FieldCount; n++)
- ReadValue (reader, objectInstance, objectId, info, metadata.MemberTypes[n], metadata.MemberNames[n], null, null);
- } else
- for (int n=0; n<metadata.FieldCount; n++) {
- if (metadata.MemberInfos [n] != null)
- ReadValue (reader, objectInstance, objectId, info, metadata.MemberTypes[n], metadata.MemberInfos[n].Name, metadata.MemberInfos[n], null);
- else if (BinaryCommon.IsPrimitive(metadata.MemberTypes[n])) {
- // Since the member info is null, the type in this
- // domain does not have this type. Even though we
- // are not going to store the value, we will read
- // it from the stream so that we can advance to the
- // next block.
- ReadPrimitiveTypeValue (reader, metadata.MemberTypes[n]);
- }
- }
- }
-
- private void RegisterObject (long objectId, object objectInstance, SerializationInfo info, long parentObjectId, MemberInfo parentObjectMemeber, int[] indices)
- {
- if (parentObjectId == 0) indices = null;
-
- if (!objectInstance.GetType().IsValueType || parentObjectId == 0)
- _manager.RegisterObject (objectInstance, objectId, info, 0, null, null);
- else
- {
- if (indices != null) indices = (int[])indices.Clone();
- _manager.RegisterObject (objectInstance, objectId, info, parentObjectId, parentObjectMemeber, indices);
- }
- }
-
- private void ReadStringIntance (BinaryReader reader, out long objectId, out object value)
- {
- objectId = (long) reader.ReadUInt32 ();
- value = reader.ReadString ();
- }
-
- private void ReadGenericArray (BinaryReader reader, out long objectId, out object val)
- {
- objectId = (long) reader.ReadUInt32 ();
- // Array structure
- reader.ReadByte();
-
- int rank = reader.ReadInt32();
-
- bool emptyDim = false;
- int[] lengths = new int[rank];
- for (int n=0; n<rank; n++)
- {
- lengths[n] = reader.ReadInt32();
- if (lengths[n] == 0) emptyDim = true;
- }
-
- TypeTag code = (TypeTag) reader.ReadByte ();
- Type elementType = ReadType (reader, code);
-
- Array array = Array.CreateInstance (elementType, lengths);
-
- if (emptyDim)
- {
- val = array;
- return;
- }
-
- int[] indices = new int[rank];
-
- // Initialize indexes
- for (int dim = rank-1; dim >= 0; dim--)
- indices[dim] = array.GetLowerBound (dim);
-
- bool end = false;
- while (!end)
- {
- ReadValue (reader, array, objectId, null, elementType, null, null, indices);
-
- for (int dim = array.Rank-1; dim >= 0; dim--)
- {
- indices[dim]++;
- if (indices[dim] > array.GetUpperBound (dim))
- {
- if (dim > 0)
- {
- indices[dim] = array.GetLowerBound (dim);
- continue; // Increment the next dimension's index
- }
- end = true; // That was the last dimension. Finished.
- }
- break;
- }
- }
- val = array;
- }
-
- private object ReadBoxedPrimitiveTypeValue (BinaryReader reader)
- {
- Type type = ReadType (reader, TypeTag.PrimitiveType);
- return ReadPrimitiveTypeValue (reader, type);
- }
-
- private void ReadArrayOfPrimitiveType (BinaryReader reader, out long objectId, out object val)
- {
- objectId = (long) reader.ReadUInt32 ();
- int length = reader.ReadInt32 ();
- Type elementType = ReadType (reader, TypeTag.PrimitiveType);
-
- switch (Type.GetTypeCode (elementType))
- {
- case TypeCode.Boolean: {
- bool[] arr = new bool [length];
- for (int n = 0; n < length; n++) arr [n] = reader.ReadBoolean();
- val = arr;
- break;
- }
-
- case TypeCode.Byte: {
- byte[] arr = new byte [length];
- int pos = 0;
- while (pos < length) {
- int nr = reader.Read (arr, pos, length - pos);
- if (nr == 0) break;
- pos += nr;
- }
- val = arr;
- break;
- }
-
- case TypeCode.Char: {
- char[] arr = new char [length];
- int pos = 0;
- while (pos < length) {
- int nr = reader.Read (arr, pos, length - pos);
- if (nr == 0) break;
- pos += nr;
- }
- val = arr;
- break;
- }
-
- case TypeCode.DateTime: {
- DateTime[] arr = new DateTime [length];
- for (int n = 0; n < length; n++) {
- arr [n] = DateTime.FromBinary (reader.ReadInt64 ());
- }
- val = arr;
- break;
- }
-
- case TypeCode.Decimal: {
- Decimal[] arr = new Decimal [length];
- for (int n = 0; n < length; n++) arr [n] = reader.ReadDecimal();
- val = arr;
- break;
- }
-
- case TypeCode.Double: {
- Double[] arr = new Double [length];
- if (length > 2)
- BlockRead (reader, arr, 8);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadDouble();
- val = arr;
- break;
- }
-
- case TypeCode.Int16: {
- short[] arr = new short [length];
- if (length > 2)
- BlockRead (reader, arr, 2);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadInt16();
- val = arr;
- break;
- }
-
- case TypeCode.Int32: {
- int[] arr = new int [length];
- if (length > 2)
- BlockRead (reader, arr, 4);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadInt32();
- val = arr;
- break;
- }
-
- case TypeCode.Int64: {
- long[] arr = new long [length];
- if (length > 2)
- BlockRead (reader, arr, 8);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadInt64();
- val = arr;
- break;
- }
-
- case TypeCode.SByte: {
- sbyte[] arr = new sbyte [length];
- if (length > 2)
- BlockRead (reader, arr, 1);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadSByte();
- val = arr;
- break;
- }
-
- case TypeCode.Single: {
- float[] arr = new float [length];
- if (length > 2)
- BlockRead (reader, arr, 4);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadSingle();
- val = arr;
- break;
- }
-
- case TypeCode.UInt16: {
- ushort[] arr = new ushort [length];
- if (length > 2)
- BlockRead (reader, arr, 2);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadUInt16();
- val = arr;
- break;
- }
-
- case TypeCode.UInt32: {
- uint[] arr = new uint [length];
- if (length > 2)
- BlockRead (reader, arr, 4);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadUInt32();
- val = arr;
- break;
- }
-
- case TypeCode.UInt64: {
- ulong[] arr = new ulong [length];
- if (length > 2)
- BlockRead (reader, arr, 8);
- else
- for (int n = 0; n < length; n++) arr [n] = reader.ReadUInt64();
- val = arr;
- break;
- }
-
- case TypeCode.String: {
- string[] arr = new string [length];
- for (int n = 0; n < length; n++) arr [n] = reader.ReadString();
- val = arr;
- break;
- }
-
- default: {
- if (elementType == typeof(TimeSpan)) {
- TimeSpan[] arr = new TimeSpan [length];
- for (int n = 0; n < length; n++) arr [n] = new TimeSpan (reader.ReadInt64 ());
- val = arr;
- }
- else
- throw new NotSupportedException ("Unsupported primitive type: " + elementType.FullName);
- break;
- }
- }
- }
-
- private void BlockRead (BinaryReader reader, Array array, int dataSize)
- {
- int totalSize = Buffer.ByteLength (array);
-
- if (arrayBuffer == null || (totalSize > arrayBuffer.Length && arrayBuffer.Length != ArrayBufferLength))
- arrayBuffer = new byte [totalSize <= ArrayBufferLength ? totalSize : ArrayBufferLength];
-
- int pos = 0;
- while (totalSize > 0) {
- int size = totalSize < arrayBuffer.Length ? totalSize : arrayBuffer.Length;
- int ap = 0;
- do {
- int nr = reader.Read (arrayBuffer, ap, size - ap);
- if (nr == 0) break;
- ap += nr;
- } while (ap < size);
-
- if (!BitConverter.IsLittleEndian && dataSize > 1)
- BinaryCommon.SwapBytes (arrayBuffer, size, dataSize);
-
- Buffer.BlockCopy (arrayBuffer, 0, array, pos, size);
- totalSize -= size;
- pos += size;
- }
- }
-
-
- private void ReadArrayOfObject (BinaryReader reader, out long objectId, out object array)
- {
- ReadSimpleArray (reader, typeof (object), out objectId, out array);
- }
-
- private void ReadArrayOfString (BinaryReader reader, out long objectId, out object array)
- {
- ReadSimpleArray (reader, typeof (string), out objectId, out array);
- }
-
- private void ReadSimpleArray (BinaryReader reader, Type elementType, out long objectId, out object val)
- {
- objectId = (long) reader.ReadUInt32 ();
- int length = reader.ReadInt32 ();
- int[] indices = new int[1];
-
- Array array = Array.CreateInstance (elementType, length);
- for (int n = 0; n < length; n++)
- {
- indices[0] = n;
- ReadValue (reader, array, objectId, null, elementType, null, null, indices);
- n = indices[0];
- }
- val = array;
- }
-
- private TypeMetadata ReadTypeMetadata (BinaryReader reader, bool isRuntimeObject, bool hasTypeInfo)
- {
- TypeMetadata metadata = new TypeMetadata();
-
- string className = reader.ReadString ();
- int fieldCount = reader.ReadInt32 ();
-
- Type[] types = new Type[fieldCount];
- string[] names = new string[fieldCount];
-
- for (int n=0; n<fieldCount; n++)
- names [n] = reader.ReadString ();
-
- if (hasTypeInfo)
- {
- TypeTag[] codes = new TypeTag[fieldCount];
-
- for (int n=0; n<fieldCount; n++)
- codes [n] = (TypeTag) reader.ReadByte ();
-
- for (int n=0; n<fieldCount; n++) {
- Type t = ReadType (reader, codes[n], false);
- // The field's type could not be resolved: assume it is an object.
- if (t == null)
- t = typeof (object);
- types [n] = t;
- }
- }
-
- // Gets the type
-
- if (!isRuntimeObject)
- {
- long assemblyId = (long)reader.ReadUInt32();
- metadata.Type = GetDeserializationType (assemblyId, className);
- }
- else
- metadata.Type = Type.GetType (className, true);
-
- metadata.MemberTypes = types;
- metadata.MemberNames = names;
- metadata.FieldCount = names.Length;
-
- // Now check if this objects needs a SerializationInfo struct for deserialziation.
- // SerializationInfo is needed if the object has to be deserialized using
- // a serialization surrogate, or if it implements ISerializable.
-
- if (_surrogateSelector != null)
- {
- // check if the surrogate selector handles objects of the given type.
- ISurrogateSelector selector;
- ISerializationSurrogate surrogate = _surrogateSelector.GetSurrogate (metadata.Type, _context, out selector);
- metadata.NeedsSerializationInfo = (surrogate != null);
- }
-
- if (!metadata.NeedsSerializationInfo)
- {
- // Check if the object is marked with the Serializable attribute
-
- if (!metadata.Type.IsSerializable)
- throw new SerializationException("Serializable objects must be marked with the Serializable attribute");
-
- metadata.NeedsSerializationInfo = typeof (ISerializable).IsAssignableFrom (metadata.Type);
- if (!metadata.NeedsSerializationInfo)
- {
- metadata.MemberInfos = new MemberInfo [fieldCount];
- for (int n=0; n<fieldCount; n++)
- {
- FieldInfo field = null;
- string memberName = names[n];
-
- int i = memberName.IndexOf ('+');
- if (i != -1) {
- string baseTypeName = names[n].Substring (0,i);
- memberName = names[n].Substring (i+1);
- Type t = metadata.Type.BaseType;
- while (t != null) {
- if (t.Name == baseTypeName) {
- field = t.GetField (memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- break;
- }
- else
- t = t.BaseType;
- }
- }
- else
- field = metadata.Type.GetField (memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
-
- if (field != null)
- metadata.MemberInfos [n] = field;
-
- if (!hasTypeInfo) {
- types [n] = field.FieldType;
- }
- }
- metadata.MemberNames = null; // Info now in MemberInfos
- }
- }
-
- // Registers the type's metadata so it can be reused later if
- // a RefTypeObject element is found
-
- if (!_typeMetadataCache.ContainsKey (metadata.Type))
- _typeMetadataCache [metadata.Type] = metadata;
-
- return metadata;
- }
-
- // Called for primitive types
- static bool IsGeneric (MemberInfo minfo)
- {
- if (minfo == null)
- return false;
-
- Type mtype = null;
- switch (minfo.MemberType) {
- case MemberTypes.Field:
- mtype = ((FieldInfo) minfo).FieldType;
- break;
- default:
- throw new NotSupportedException ("Not supported: " + minfo.MemberType);
- }
- return (mtype != null && mtype.IsGenericType);
- }
-
- private void ReadValue (BinaryReader reader, object parentObject, long parentObjectId, SerializationInfo info, Type valueType, string fieldName, MemberInfo memberInfo, int[] indices)
- {
- // Reads a value from the stream and assigns it to the member of an object
-
- object val;
-
- if (BinaryCommon.IsPrimitive (valueType) && !IsGeneric (memberInfo))
- {
- val = ReadPrimitiveTypeValue (reader, valueType);
- SetObjectValue (parentObject, fieldName, memberInfo, info, val, valueType, indices);
- return;
- }
-
- // Gets the object
-
- BinaryElement element = (BinaryElement)reader.ReadByte ();
-
- if (element == BinaryElement.ObjectReference)
- {
- // Just read the id of the referred object and record a fixup
- long childObjectId = (long) reader.ReadUInt32();
- RecordFixup (parentObjectId, childObjectId, parentObject, info, fieldName, memberInfo, indices);
- return;
- }
-
- long objectId;
- SerializationInfo objectInfo;
-
- ReadObject (element, reader, out objectId, out val, out objectInfo);
-
- // There are two cases where the object cannot be assigned to the parent
- // and a fixup must be used:
- // 1) When what has been read is not an object, but an id of an object that
- // has not been read yet (an object reference). This is managed in the
- // previous block of code.
- // 2) When the read object is a value type object. Value type fields hold
- // copies of objects, not references. Thus, if the value object that
- // has been read has pending fixups, those fixups would be made to the
- // boxed copy in the ObjectManager, and not in the required object instance
-
- // First of all register the fixup, and then the object. ObjectManager is more
- // efficient if done in this order
-
- bool hasFixup = false;
- if (objectId != 0)
- {
- if (val.GetType().IsValueType)
- {
- RecordFixup (parentObjectId, objectId, parentObject, info, fieldName, memberInfo, indices);
- hasFixup = true;
- }
-
- // Register the value
-
- if (info == null && !(parentObject is Array))
- RegisterObject (objectId, val, objectInfo, parentObjectId, memberInfo, null);
- else
- RegisterObject (objectId, val, objectInfo, parentObjectId, null, indices);
- }
- // Assign the value to the parent object, unless there is a fixup
-
- if (!hasFixup)
- SetObjectValue (parentObject, fieldName, memberInfo, info, val, valueType, indices);
- }
-
- private void SetObjectValue (object parentObject, string fieldName, MemberInfo memberInfo, SerializationInfo info, object value, Type valueType, int[] indices)
- {
- if (value is IObjectReference)
- value = ((IObjectReference)value).GetRealObject (_context);
-
- if (parentObject is Array)
- {
- if (value is ArrayNullFiller)
- {
- // It must be a single dimension array of objects.
- // Just increase the index. Elements are null by default.
- int count = ((ArrayNullFiller)value).NullCount;
- indices[0] += count - 1;
- }
- else
- ((Array)parentObject).SetValue (value, indices);
- }
- else if (info != null) {
- info.AddValue (fieldName, value, valueType);
- }
- else {
- if (memberInfo is FieldInfo)
- ((FieldInfo)memberInfo).SetValue (parentObject, value);
- else
- ((PropertyInfo)memberInfo).SetValue (parentObject, value, null);
- }
- }
-
- private void RecordFixup (long parentObjectId, long childObjectId, object parentObject, SerializationInfo info, string fieldName, MemberInfo memberInfo, int[] indices)
- {
- if (info != null) {
- _manager.RecordDelayedFixup (parentObjectId, fieldName, childObjectId);
- }
- else if (parentObject is Array) {
- if (indices.Length == 1)
- _manager.RecordArrayElementFixup (parentObjectId, indices[0], childObjectId);
- else
- _manager.RecordArrayElementFixup (parentObjectId, (int[])indices.Clone(), childObjectId);
- }
- else {
- _manager.RecordFixup (parentObjectId, memberInfo, childObjectId);
- }
- }
-
- private Type GetDeserializationType (long assemblyId, string className)
- {
- return GetDeserializationType (assemblyId, className, true);
- }
-
- private Type GetDeserializationType (long assemblyId, string className, bool throwOnError)
- {
- Type t;
- string assemblyName = (string)_registeredAssemblies[assemblyId];
-
- if (_binder != null) {
- t = _binder.BindToType (assemblyName, className);
- if (t != null)
- return t;
- }
-
- Assembly assembly;
- try {
- assembly = Assembly.Load (assemblyName);
- } catch (Exception ex) {
- if (!throwOnError)
- return null;
- throw new SerializationException (String.Format ("Couldn't find assembly '{0}'", assemblyName), ex);
- }
-
- t = assembly.GetType (className);
- if (t != null)
- return t;
-
- if (!throwOnError)
- return null;
-
- throw new SerializationException (String.Format ("Couldn't find type '{0}' in assembly '{1}'", className, assemblyName));
- }
-
- public Type ReadType (BinaryReader reader, TypeTag code)
- {
- return ReadType (reader, code, true);
- }
-
- public Type ReadType (BinaryReader reader, TypeTag code, bool throwOnError)
- {
- switch (code)
- {
- case TypeTag.PrimitiveType:
- return BinaryCommon.GetTypeFromCode (reader.ReadByte());
-
- case TypeTag.String:
- return typeof(string);
-
- case TypeTag.ObjectType:
- return typeof(object);
-
- case TypeTag.RuntimeType:
- {
- string name = reader.ReadString ();
- // map MS.NET's System.RuntimeType to System.MonoType
- if (_context.State == StreamingContextStates.Remoting)
- if (name == "System.RuntimeType")
- return typeof (MonoType);
- else if (name == "System.RuntimeType[]")
- return typeof (MonoType[]);
- Type t = Type.GetType (name);
- if (t != null)
- return t;
-
- throw new SerializationException (String.Format ("Could not find type '{0}'.", name));
- }
-
- case TypeTag.GenericType:
- {
- string name = reader.ReadString ();
- long asmid = (long) reader.ReadUInt32();
- return GetDeserializationType (asmid, name, throwOnError);
- }
-
- case TypeTag.ArrayOfObject:
- return typeof(object[]);
-
- case TypeTag.ArrayOfString:
- return typeof(string[]);
-
- case TypeTag.ArrayOfPrimitiveType:
- Type elementType = BinaryCommon.GetTypeFromCode (reader.ReadByte());
- return Type.GetType(elementType.FullName + "[]");
-
- default:
- throw new NotSupportedException ("Unknow type tag");
- }
- }
-
- public static object ReadPrimitiveTypeValue (BinaryReader reader, Type type)
- {
- if (type == null) return null;
-
- switch (Type.GetTypeCode (type))
- {
- case TypeCode.Boolean:
- return reader.ReadBoolean();
-
- case TypeCode.Byte:
- return reader.ReadByte();
-
- case TypeCode.Char:
- return reader.ReadChar();
-
- case TypeCode.DateTime:
- return DateTime.FromBinary (reader.ReadInt64());
-
- case TypeCode.Decimal:
- return Decimal.Parse (reader.ReadString(), CultureInfo.InvariantCulture);
-
- case TypeCode.Double:
- return reader.ReadDouble();
-
- case TypeCode.Int16:
- return reader.ReadInt16();
-
- case TypeCode.Int32:
- return reader.ReadInt32();
-
- case TypeCode.Int64:
- return reader.ReadInt64();
-
- case TypeCode.SByte:
- return reader.ReadSByte();
-
- case TypeCode.Single:
- return reader.ReadSingle();
-
- case TypeCode.UInt16:
- return reader.ReadUInt16();
-
- case TypeCode.UInt32:
- return reader.ReadUInt32();
-
- case TypeCode.UInt64:
- return reader.ReadUInt64();
-
- case TypeCode.String:
- return reader.ReadString();
-
- default:
- if (type == typeof(TimeSpan))
- return new TimeSpan (reader.ReadInt64 ());
- else
- throw new NotSupportedException ("Unsupported primitive type: " + type.FullName);
- }
- }
- }
-}
+++ /dev/null
-// ObjectWriter.cs
-//
-// Author:
-// Lluis Sanchez Gual (lluis@ideary.com)
-//
-// (C) 2003 Lluis Sanchez Gual
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using System.Collections;
-using System.Runtime.Serialization;
-using System.Runtime.Remoting.Messaging;
-using System.Reflection;
-using System.Globalization;
-
-namespace System.Runtime.Serialization.Formatters.Binary
-{
- abstract class TypeMetadata
- {
- public string TypeAssemblyName;
- public string InstanceTypeName;
-
- public abstract void WriteAssemblies (ObjectWriter ow, BinaryWriter writer);
- public abstract void WriteTypeData (ObjectWriter ow, BinaryWriter writer, bool writeTypes);
- public abstract void WriteObjectData (ObjectWriter ow, BinaryWriter writer, object data);
-
- public virtual bool IsCompatible (TypeMetadata other)
- {
- return true;
- }
-
- public void BindToName (string assemblyName, string typeName)
- {
- if (assemblyName != null)
- TypeAssemblyName = assemblyName;
- if (typeName != null)
- InstanceTypeName = typeName;
- }
-
- public abstract bool RequiresTypes { get; }
- }
-
- abstract class ClrTypeMetadata: TypeMetadata
- {
- public Type InstanceType;
-
- public ClrTypeMetadata (Type instanceType)
- {
- InstanceType = instanceType;
- InstanceTypeName = instanceType.FullName;
- TypeAssemblyName = instanceType.Assembly.FullName;
- }
-
- public override bool RequiresTypes {
- get { return false; }
- }
- }
-
- class SerializableTypeMetadata: TypeMetadata
- {
- Type[] types;
- string[] names;
-
- public SerializableTypeMetadata (Type itype, SerializationInfo info)
- {
- types = new Type [info.MemberCount];
- names = new string [info.MemberCount];
-
- SerializationInfoEnumerator e = info.GetEnumerator ();
-
- int n = 0;
- while (e.MoveNext ())
- {
- types[n] = e.ObjectType;
- names[n] = e.Name;
- n++;
- }
-
- TypeAssemblyName = info.AssemblyName;
- InstanceTypeName = info.FullTypeName;
- }
-
- public override bool IsCompatible (TypeMetadata other)
- {
- if (!(other is SerializableTypeMetadata)) return false;
-
- SerializableTypeMetadata tm = (SerializableTypeMetadata)other;
- if (types.Length != tm.types.Length) return false;
- if (TypeAssemblyName != tm.TypeAssemblyName) return false;
- if (InstanceTypeName != tm.InstanceTypeName) return false;
- for (int n=0; n<types.Length; n++)
- {
- if (types[n] != tm.types[n]) return false;
- if (names[n] != tm.names[n]) return false;
- }
- return true;
- }
-
- public override void WriteAssemblies (ObjectWriter ow, BinaryWriter writer)
- {
- foreach (Type mtype in types)
- {
- Type type = mtype;
- while (type.IsArray)
- type = type.GetElementType();
-
- ow.WriteAssembly (writer, type.Assembly);
- }
- }
-
- public override void WriteTypeData (ObjectWriter ow, BinaryWriter writer, bool writeTypes)
- {
- writer.Write (types.Length);
-
- // Names of fields
- foreach (string name in names)
- writer.Write (name);
-
- // Types of fields
- foreach (Type type in types)
- ObjectWriter.WriteTypeCode (writer, type);
-
- // Type specs of fields
- foreach (Type type in types)
- ow.WriteTypeSpec (writer, type);
- }
-
- public override void WriteObjectData (ObjectWriter ow, BinaryWriter writer, object data)
- {
- SerializationInfo info = (SerializationInfo) data;
- SerializationInfoEnumerator e = info.GetEnumerator ();
-
- while (e.MoveNext ())
- ow.WriteValue (writer, e.ObjectType, e.Value);
- }
-
- public override bool RequiresTypes {
- get { return true; }
- }
- }
-
- class MemberTypeMetadata: ClrTypeMetadata
- {
- MemberInfo[] members;
-
- public MemberTypeMetadata (Type type, StreamingContext context): base (type)
- {
- members = FormatterServices.GetSerializableMembers (type, context);
- }
-
- public override void WriteAssemblies (ObjectWriter ow, BinaryWriter writer)
- {
- foreach (FieldInfo field in members)
- {
- Type type = field.FieldType;
- while (type.IsArray)
- type = type.GetElementType();
-
- ow.WriteAssembly (writer, type.Assembly);
- }
- }
-
- public override void WriteTypeData (ObjectWriter ow, BinaryWriter writer, bool writeTypes)
- {
- writer.Write (members.Length);
-
- // Names of fields
- foreach (FieldInfo field in members)
- writer.Write (field.Name);
-
- if (writeTypes) {
- // Types of fields
- foreach (FieldInfo field in members)
- ObjectWriter.WriteTypeCode (writer, field.FieldType);
-
- // Type specs of fields
- foreach (FieldInfo field in members)
- ow.WriteTypeSpec (writer, field.FieldType);
- }
- }
-
- public override void WriteObjectData (ObjectWriter ow, BinaryWriter writer, object data)
- {
- object[] values = FormatterServices.GetObjectData (data, members);
- for (int n=0; n<values.Length; n++)
- ow.WriteValue (writer, ((FieldInfo)members[n]).FieldType, values[n]);
- }
- }
-
- internal class ObjectWriter
- {
- ObjectIDGenerator _idGenerator = new ObjectIDGenerator();
- Hashtable _cachedMetadata = new Hashtable();
- Queue _pendingObjects = new Queue();
- Hashtable _assemblyCache = new Hashtable();
-
- // Type metadata that can be shared with all serializers
- static Hashtable _cachedTypes = new Hashtable();
-
- internal static Assembly CorlibAssembly = typeof(string).Assembly;
- internal static string CorlibAssemblyName = typeof(string).Assembly.FullName;
-
- ISurrogateSelector _surrogateSelector;
- StreamingContext _context;
- FormatterAssemblyStyle _assemblyFormat;
- FormatterTypeStyle _typeFormat;
- SerializationBinder _binder;
- byte[] arrayBuffer;
- int ArrayBufferLength = 4096;
- SerializationObjectManager _manager;
-
- class MetadataReference
- {
- public TypeMetadata Metadata;
- public long ObjectID;
-
- public MetadataReference (TypeMetadata metadata, long id)
- {
- Metadata = metadata;
- ObjectID = id;
- }
- }
-
- public ObjectWriter (BinaryFormatter formatter)
- {
- _surrogateSelector = formatter.SurrogateSelector;
- _context = formatter.Context;
- _assemblyFormat = formatter.AssemblyFormat;
- _typeFormat = formatter.TypeFormat;
- _manager = new SerializationObjectManager (formatter.Context);
- _binder = formatter.Binder;
- }
-
- public void WriteObjectGraph (BinaryWriter writer, object obj, Header[] headers)
- {
- _pendingObjects.Clear();
- if (headers != null) QueueObject (headers);
- QueueObject (obj);
- WriteQueuedObjects (writer);
- WriteSerializationEnd (writer);
- _manager.RaiseOnSerializedEvent ();
- }
-
- public void QueueObject (object obj)
- {
- _pendingObjects.Enqueue (obj);
- }
-
- public void WriteQueuedObjects (BinaryWriter writer)
- {
- while (_pendingObjects.Count > 0)
- WriteObjectInstance (writer, _pendingObjects.Dequeue(), false);
- }
-
- public void WriteObjectInstance (BinaryWriter writer, object obj, bool isValueObject)
- {
- bool firstTime;
- long id;
-
- // If the object is a value type (not boxed) then there is no need
- // to register it in the id generator, because it won't have other
- // references to it
-
- if (isValueObject) id = _idGenerator.NextId;
- else id = _idGenerator.GetId (obj, out firstTime);
-
- if (obj is string) {
- WriteString (writer, id, (string)obj);
- }
- else if (obj is Array) {
- WriteArray (writer, id, (Array)obj);
- }
- else
- WriteObject (writer, id, obj);
- }
-
- public static void WriteSerializationEnd (BinaryWriter writer)
- {
- writer.Write ((byte) BinaryElement.End);
- }
-
- private void WriteObject (BinaryWriter writer, long id, object obj)
- {
- object data;
- TypeMetadata metadata;
-
- GetObjectData (obj, out metadata, out data);
- MetadataReference metadataReference = (MetadataReference)_cachedMetadata [metadata.InstanceTypeName];
-
- if (metadataReference != null && metadata.IsCompatible (metadataReference.Metadata))
- {
- // An object of the same type has already been serialized
- // It is not necessary to write again type metadata
-
- writer.Write ((byte) BinaryElement.RefTypeObject);
- writer.Write ((int)id);
-
- writer.Write ((int)metadataReference.ObjectID);
- metadata.WriteObjectData (this, writer, data);
- return;
- }
-
- if (metadataReference == null)
- {
- metadataReference = new MetadataReference (metadata, id);
- _cachedMetadata [metadata.InstanceTypeName] = metadataReference;
- }
-
- bool writeTypes = metadata.RequiresTypes || _typeFormat == FormatterTypeStyle.TypesAlways;
-
- BinaryElement objectTag;
-
- int assemblyId;
- if (metadata.TypeAssemblyName == CorlibAssemblyName)
- {
- // A corlib type
- objectTag = writeTypes ? BinaryElement.RuntimeObject : BinaryElement.UntypedRuntimeObject;
- assemblyId = -1;
- }
- else
- {
- objectTag = writeTypes ? BinaryElement.ExternalObject : BinaryElement.UntypedExternalObject;
- assemblyId = WriteAssemblyName (writer, metadata.TypeAssemblyName);
- }
-
- // Registers the assemblies needed for each field
- // If there are assemblies that where not registered before this object,
- // write them now
-
- metadata.WriteAssemblies (this, writer);
-
- // Writes the object
-
- writer.Write ((byte) objectTag);
- writer.Write ((int)id);
- writer.Write (metadata.InstanceTypeName);
-
- metadata.WriteTypeData (this, writer, writeTypes);
- if (assemblyId != -1) writer.Write (assemblyId);
-
- metadata.WriteObjectData (this, writer, data);
- }
-
- private void GetObjectData (object obj, out TypeMetadata metadata, out object data)
- {
- Type instanceType = obj.GetType();
- string binderAssemblyName = null;
- string binderTypeName = null;
- if (_binder != null)
- _binder.BindToName (instanceType, out binderAssemblyName, out binderTypeName);
- // Check if the formatter has a surrogate selector, if it does,
- // check if the surrogate selector handles objects of the given type.
-
- if (_surrogateSelector != null)
- {
- ISurrogateSelector selector;
- ISerializationSurrogate surrogate = _surrogateSelector.GetSurrogate (instanceType, _context, out selector);
- if (surrogate != null)
- {
- SerializationInfo info = new SerializationInfo (instanceType, new FormatterConverter ());
- surrogate.GetObjectData (obj, info, _context);
- metadata = new SerializableTypeMetadata (instanceType, info);
- if (_binder != null)
- metadata.BindToName (binderAssemblyName, binderTypeName);
-
- data = info;
- return;
- }
- }
-
- // Check if the object is marked with the Serializable attribute
-
- BinaryCommon.CheckSerializable (instanceType, _surrogateSelector, _context);
-
- _manager.RegisterObject (obj);
-
- ISerializable ser = obj as ISerializable;
-
- if (ser != null)
- {
- SerializationInfo info = new SerializationInfo (instanceType, new FormatterConverter ());
- ser.GetObjectData (info, _context);
- metadata = new SerializableTypeMetadata (instanceType, info);
- if (_binder != null)
- metadata.BindToName (binderAssemblyName, binderTypeName);
-
- data = info;
- }
- else
- {
- data = obj;
- if (_context.Context != null)
- {
- // Don't cache metadata info when the Context property is not null sice
- // we can't control the number of possible contexts in this case
- metadata = new MemberTypeMetadata (instanceType, _context);
- if (_binder != null)
- metadata.BindToName (binderAssemblyName, binderTypeName);
-
- return;
- }
-
- Hashtable typesTable;
- bool isNew = false;
- lock (_cachedTypes) {
- typesTable = (Hashtable) _cachedTypes [_context.State];
- if (typesTable == null) {
- typesTable = new Hashtable ();
- _cachedTypes [_context.State] = typesTable;
- isNew = true;
- }
- }
-
- metadata = null;
- lock (typesTable) {
- if (!isNew) {
- metadata = (TypeMetadata) typesTable [instanceType];
- }
-
- if (metadata == null) {
- metadata = CreateMemberTypeMetadata (instanceType);
- if (_binder != null)
- metadata.BindToName (binderAssemblyName, binderTypeName);
- }
-
- typesTable [instanceType] = metadata;
- }
- }
- }
-
- TypeMetadata CreateMemberTypeMetadata (Type type)
- {
-#if !FULL_AOT_RUNTIME
- if (!BinaryCommon.UseReflectionSerialization) {
- Type metaType = CodeGenerator.GenerateMetadataType (type, _context);
- return (TypeMetadata) Activator.CreateInstance (metaType);
- }
- else
-#endif
- return new MemberTypeMetadata (type, _context);
- }
-
- private void WriteArray (BinaryWriter writer, long id, Array array)
- {
- // There are 4 ways of serializing arrays:
- // The element GenericArray (7) can be used for all arrays.
- // The element ArrayOfPrimitiveType (15) can be used for single-dimensional
- // arrays of primitive types
- // The element ArrayOfObject (16) can be used for single-dimensional Object arrays
- // The element ArrayOfString (17) can be used for single-dimensional string arrays
-
- Type elementType = array.GetType().GetElementType();
-
- if (elementType == typeof (object) && array.Rank == 1) {
- WriteObjectArray (writer, id, array);
- }
- else if (elementType == typeof (string) && array.Rank == 1) {
- WriteStringArray (writer, id, array);
- }
- else if (BinaryCommon.IsPrimitive(elementType) && array.Rank == 1) {
- WritePrimitiveTypeArray (writer, id, array);
- }
- else
- WriteGenericArray (writer, id, array);
- }
-
- private void WriteGenericArray (BinaryWriter writer, long id, Array array)
- {
- Type elementType = array.GetType().GetElementType();
-
- // Registers and writes the assembly of the array element type if needed
-
- var tag = GetTypeTag (elementType);
- if ((tag != TypeTag.ArrayOfObject) && (tag != TypeTag.ArrayOfString) && (tag != TypeTag.ArrayOfPrimitiveType))
- WriteAssembly (writer, elementType.Assembly);
-
- // Writes the array
-
- writer.Write ((byte) BinaryElement.GenericArray);
- writer.Write ((int)id);
-
- // Write the structure of the array
-
- if (elementType.IsArray)
- writer.Write ((byte) ArrayStructure.Jagged);
- else if (array.Rank == 1)
- writer.Write ((byte) ArrayStructure.SingleDimensional);
- else
- writer.Write ((byte) ArrayStructure.MultiDimensional);
-
- // Write the number of dimensions and the length
- // of each dimension
-
- writer.Write (array.Rank);
- for (int n=0; n<array.Rank; n++)
- writer.Write (array.GetUpperBound (n) + 1);
-
- // Writes the type
- WriteTypeCode (writer, elementType);
- WriteTypeSpec (writer, elementType);
-
- // Writes the values. For single-dimension array, a special tag is used
- // to represent multiple consecutive null values. I don't know why this
- // optimization is not used for multidimensional arrays.
-
- if (array.Rank == 1 && !elementType.IsValueType)
- {
- WriteSingleDimensionArrayElements (writer, array, elementType);
- }
- else
- {
- foreach (object item in array)
- WriteValue (writer, elementType, item);
- }
- }
-
- private void WriteObjectArray (BinaryWriter writer, long id, Array array)
- {
- writer.Write ((byte) BinaryElement.ArrayOfObject);
- writer.Write ((int)id);
- writer.Write (array.Length); // Single dimension. Just write the length
- WriteSingleDimensionArrayElements (writer, array, typeof (object));
- }
-
- private void WriteStringArray (BinaryWriter writer, long id, Array array)
- {
- writer.Write ((byte) BinaryElement.ArrayOfString);
- writer.Write ((int)id);
- writer.Write (array.Length); // Single dimension. Just write the length
- WriteSingleDimensionArrayElements (writer, array, typeof (string));
- }
-
- private void WritePrimitiveTypeArray (BinaryWriter writer, long id, Array array)
- {
- writer.Write ((byte) BinaryElement.ArrayOfPrimitiveType);
- writer.Write ((int)id);
- writer.Write (array.Length); // Single dimension. Just write the length
-
- Type elementType = array.GetType().GetElementType();
- WriteTypeSpec (writer, elementType);
-
- switch (Type.GetTypeCode (elementType))
- {
- case TypeCode.Boolean:
- foreach (bool item in (bool[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.Byte:
- writer.Write ((byte[]) array);
- break;
-
- case TypeCode.Char:
- writer.Write ((char[]) array);
- break;
-
- case TypeCode.DateTime:
- foreach (DateTime item in (DateTime[]) array)
- writer.Write (item.ToBinary ());
- break;
-
- case TypeCode.Decimal:
- foreach (decimal item in (decimal[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.Double:
- if (array.Length > 2)
- BlockWrite (writer, array, 8);
- else
- foreach (double item in (double[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.Int16:
- if (array.Length > 2)
- BlockWrite (writer, array, 2);
- else
- foreach (short item in (short[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.Int32:
- if (array.Length > 2)
- BlockWrite (writer, array, 4);
- else
- foreach (int item in (int[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.Int64:
- if (array.Length > 2)
- BlockWrite (writer, array, 8);
- else
- foreach (long item in (long[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.SByte:
- if (array.Length > 2)
- BlockWrite (writer, array, 1);
- else
- foreach (sbyte item in (sbyte[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.Single:
- if (array.Length > 2)
- BlockWrite (writer, array, 4);
- else
- foreach (float item in (float[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.UInt16:
- if (array.Length > 2)
- BlockWrite (writer, array, 2);
- else
- foreach (ushort item in (ushort[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.UInt32:
- if (array.Length > 2)
- BlockWrite (writer, array, 4);
- else
- foreach (uint item in (uint[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.UInt64:
- if (array.Length > 2)
- BlockWrite (writer, array, 8);
- else
- foreach (ulong item in (ulong[]) array)
- writer.Write (item);
- break;
-
- case TypeCode.String:
- foreach (string item in (string[]) array)
- writer.Write (item);
- break;
-
- default:
- if (elementType == typeof (TimeSpan)) {
- foreach (TimeSpan item in (TimeSpan[]) array)
- writer.Write (item.Ticks);
- }
- else
- throw new NotSupportedException ("Unsupported primitive type: " + elementType.FullName);
- break;
- }
- }
-
- private void BlockWrite (BinaryWriter writer, Array array, int dataSize)
- {
- int totalSize = Buffer.ByteLength (array);
-
- if (arrayBuffer == null || (totalSize > arrayBuffer.Length && arrayBuffer.Length != ArrayBufferLength))
- arrayBuffer = new byte [totalSize <= ArrayBufferLength ? totalSize : ArrayBufferLength];
-
- int pos = 0;
- while (totalSize > 0) {
- int size = totalSize < arrayBuffer.Length ? totalSize : arrayBuffer.Length;
- Buffer.BlockCopy (array, pos, arrayBuffer, 0, size);
-
- if (!BitConverter.IsLittleEndian && dataSize > 1)
- BinaryCommon.SwapBytes (arrayBuffer, size, dataSize);
-
- writer.Write (arrayBuffer, 0, size);
- totalSize -= size;
- pos += size;
- }
- }
-
- private void WriteSingleDimensionArrayElements (BinaryWriter writer, Array array, Type elementType)
- {
- int numNulls = 0;
- foreach (object val in array)
- {
- if (val != null && numNulls > 0)
- {
- WriteNullFiller (writer, numNulls);
- WriteValue (writer, elementType, val);
- numNulls = 0;
- }
- else if (val == null)
- numNulls++;
- else
- WriteValue (writer, elementType, val);
- }
- if (numNulls > 0)
- WriteNullFiller (writer, numNulls);
- }
-
- private void WriteNullFiller (BinaryWriter writer, int numNulls)
- {
- if (numNulls == 1) {
- writer.Write ((byte) BinaryElement.NullValue);
- }
- else if (numNulls == 2) {
- writer.Write ((byte) BinaryElement.NullValue);
- writer.Write ((byte) BinaryElement.NullValue);
- }
- else if (numNulls <= byte.MaxValue) {
- writer.Write ((byte) BinaryElement.ArrayFiller8b);
- writer.Write ((byte) numNulls);
- }
- else {
- writer.Write ((byte) BinaryElement.ArrayFiller32b);
- writer.Write (numNulls);
- }
- }
-
- private void WriteObjectReference (BinaryWriter writer, long id)
- {
-
- writer.Write ((byte) BinaryElement.ObjectReference);
- writer.Write ((int)id);
- }
-
- public void WriteValue (BinaryWriter writer, Type valueType, object val)
- {
- if (val == null)
- {
- BinaryCommon.CheckSerializable (valueType, _surrogateSelector, _context);
- writer.Write ((byte) BinaryElement.NullValue);
- }
- else if (BinaryCommon.IsPrimitive(val.GetType()))
- {
- if (!BinaryCommon.IsPrimitive(valueType))
- {
- // It is a boxed primitive type value
- writer.Write ((byte) BinaryElement.BoxedPrimitiveTypeValue);
- WriteTypeSpec (writer, val.GetType());
- }
- WritePrimitiveValue (writer, val);
- }
- else if (valueType.IsValueType)
- {
- // Value types are written embedded in the containing object
- WriteObjectInstance (writer, val, true);
- }
- else if (val is string)
- {
- // Strings are written embedded, unless already registered
- bool firstTime;
- long id = _idGenerator.GetId (val, out firstTime);
-
- if (firstTime) WriteObjectInstance (writer, val, false);
- else WriteObjectReference (writer, id);
- }
- else
- {
- // It is a reference type. Write a forward reference and queue the
- // object to the pending object list (unless already written).
-
- bool firstTime;
- long id = _idGenerator.GetId (val, out firstTime);
-
- if (firstTime) _pendingObjects.Enqueue (val);
- WriteObjectReference (writer, id);
- }
- }
-
- private void WriteString (BinaryWriter writer, long id, string str)
- {
- writer.Write ((byte) BinaryElement.String);
- writer.Write ((int)id);
- writer.Write (str);
- }
-
- public int WriteAssembly (BinaryWriter writer, Assembly assembly)
- {
- return WriteAssemblyName (writer, assembly.FullName);
- }
-
- public int WriteAssemblyName (BinaryWriter writer, string assembly)
- {
- if (assembly == ObjectWriter.CorlibAssemblyName) return -1;
-
- bool firstTime;
- int id = RegisterAssembly (assembly, out firstTime);
- if (!firstTime) return id;
-
- writer.Write ((byte) BinaryElement.Assembly);
- writer.Write (id);
- if (_assemblyFormat == FormatterAssemblyStyle.Full)
- writer.Write (assembly);
- else {
- int i = assembly.IndexOf (',');
- if (i != -1) assembly = assembly.Substring (0, i);
- writer.Write (assembly);
- }
-
- return id;
- }
-
- public int GetAssemblyId (Assembly assembly)
- {
- return GetAssemblyNameId (assembly.FullName);
- }
-
- public int GetAssemblyNameId (string assembly)
- {
- return (int)_assemblyCache[assembly];
- }
-
- private int RegisterAssembly (string assembly, out bool firstTime)
- {
- if (_assemblyCache.ContainsKey (assembly))
- {
- firstTime = false;
- return (int)_assemblyCache[assembly];
- }
- else
- {
- int id = (int)_idGenerator.GetId (0, out firstTime);
- _assemblyCache.Add (assembly, id);
- return id;
- }
- }
-
- public static void WritePrimitiveValue (BinaryWriter writer, object value)
- {
- Type type = value.GetType();
-
- switch (Type.GetTypeCode (type))
- {
- case TypeCode.Boolean:
- writer.Write ((bool)value);
- break;
-
- case TypeCode.Byte:
- writer.Write ((byte) value);
- break;
-
- case TypeCode.Char:
- writer.Write ((char) value);
- break;
-
- case TypeCode.DateTime:
- writer.Write ( ((DateTime)value).ToBinary ());
- break;
-
- case TypeCode.Decimal:
- writer.Write (((decimal) value).ToString (CultureInfo.InvariantCulture));
- break;
-
- case TypeCode.Double:
- writer.Write ((double) value);
- break;
-
- case TypeCode.Int16:
- writer.Write ((short) value);
- break;
-
- case TypeCode.Int32:
- writer.Write ((int) value);
- break;
-
- case TypeCode.Int64:
- writer.Write ((long) value);
- break;
-
- case TypeCode.SByte:
- writer.Write ((sbyte) value);
- break;
-
- case TypeCode.Single:
- writer.Write ((float) value);
- break;
-
- case TypeCode.UInt16:
- writer.Write ((ushort) value);
- break;
-
- case TypeCode.UInt32:
- writer.Write ((uint) value);
- break;
-
- case TypeCode.UInt64:
- writer.Write ((ulong) value);
- break;
-
- case TypeCode.String:
- writer.Write ((string) value);
- break;
-
- default:
- if (type == typeof (TimeSpan))
- writer.Write (((TimeSpan)value).Ticks);
- else
- throw new NotSupportedException ("Unsupported primitive type: " + value.GetType().FullName);
- break;
- }
- }
-
- public static void WriteTypeCode (BinaryWriter writer, Type type)
- {
- writer.Write ((byte) GetTypeTag (type));
- }
-
- public static TypeTag GetTypeTag (Type type)
- {
- if (type == typeof (string)) {
- return TypeTag.String;
- }
- else if (BinaryCommon.IsPrimitive (type)) {
- return TypeTag.PrimitiveType;
- }
- else if (type == typeof (object)) {
- return TypeTag.ObjectType;
- }
- else if (type.IsArray && type.GetArrayRank() == 1 && type.GetElementType() == typeof (object)) {
- return TypeTag.ArrayOfObject;
- }
- else if (type.IsArray && type.GetArrayRank() == 1 && type.GetElementType() == typeof (string)){
- return TypeTag.ArrayOfString;
- }
- else if (type.IsArray && type.GetArrayRank() == 1 && BinaryCommon.IsPrimitive(type.GetElementType())) {
- return TypeTag.ArrayOfPrimitiveType;
- }
- else if (type.Assembly == CorlibAssembly) {
- return TypeTag.RuntimeType;
- }
- else
- return TypeTag.GenericType;
- }
-
- public void WriteTypeSpec (BinaryWriter writer, Type type)
- {
- // WARNING Keep in sync with EmitWriteTypeSpec
-
- switch (GetTypeTag (type))
- {
- case TypeTag.PrimitiveType:
- writer.Write (BinaryCommon.GetTypeCode (type));
- break;
-
- case TypeTag.RuntimeType:
- string fullName = type.FullName;
- // Map System.MonoType to MS.NET's System.RuntimeType,
- // when called in remoting context.
- // Note that this code does not need to be in sync with
- // EmitWriteTypeSpec because serializing a MethodCall
- // won't trigger the CodeGenerator.
- if (_context.State == StreamingContextStates.Remoting)
- if (type == typeof (System.MonoType))
- fullName = "System.RuntimeType";
- else if (type == typeof (System.MonoType[]))
- fullName = "System.RuntimeType[]";
- writer.Write (fullName);
- break;
-
- case TypeTag.GenericType:
- writer.Write (type.FullName);
- writer.Write ((int)GetAssemblyId (type.Assembly));
- break;
-
- case TypeTag.ArrayOfPrimitiveType:
- writer.Write (BinaryCommon.GetTypeCode (type.GetElementType()));
- break;
-
- default:
- // Type spec not needed
- break;
- }
- }
- }
-}
+++ /dev/null
-<html>\r
- <head>\r
- <title>Binary Serialization Format</title>\r
- <style> body { FONT-SIZE: x-small; FONT-FAMILY: arial }\r
- table { FONT-SIZE: x-small; FONT-FAMILY: arial }\r
- </style>\r
- </head>\r
- <body>\r
- <H1>Binary Serialization Format</H1>\r
- <P>by Lluis Sanchez Gual (<A href="mailto:lluis@ideary.com">lluis@ideary.com</A>)</P>\r
- <UL>\r
- <LI>\r
- <A href="#intro">Introduction</A>\r
- <LI>\r
- <A href="#format">Format description</A>\r
- <UL>\r
- <LI>\r
- <A href="#example">An example</A></LI></UL>\r
- <LI>\r
- <A href="#elements">Binary elements</A>\r
- <UL>\r
- <LI>\r
- <A href="#elem1">1 - RefTypeObject</A>\r
- <LI>\r
- <A href="#elem4">4 - RuntimeObject</A>\r
- <LI>\r
- <A href="#elem5">5 - ExternalObject</A>\r
- <LI>\r
- <A href="#elem6">6 - String</A>\r
- <LI>\r
- <A href="#elem7">7 - GenericArray</A>\r
- <LI>\r
- <A href="#elem8">8 - BoxedPrimitiveTypeValue</A>\r
- <LI>\r
- <A href="#elem9">9 - ObjectReference</A>\r
- <LI>\r
- <A href="#elem10">10 - NullValue</A>\r
- <LI>\r
- <A href="#elem11">11 - End</A>\r
- <LI>\r
- <A href="#elem12">12 - Assembly</A>\r
- <LI>\r
- <A href="#elem13">13 - ArrayFiller8b</A>\r
- <LI>\r
- <A href="#elem14">14 - ArrayFiller32b</A>\r
- <LI>\r
- <A href="#elem15">15 - ArrayOfPrimitiveType</A>\r
- <LI>\r
- <A href="#elem16">16 - ArrayOfObject</A>\r
- <LI>\r
- <A href="#elem17">17 - ArrayOfString</A>\r
- <LI>\r
- <A href="#elem21">21 - MethodCall</A>\r
- <LI>\r
- <A href="#elem22">22 - MethodResponse</A></LI></UL>\r
- <LI>\r
- <A href="#other">Other Elements</A>\r
- </LI>\r
- <UL>\r
- <LI>\r
- <A href="#string">string</A>\r
- <LI>\r
- <A href="#primitive-value">primitive-value</A>\r
- <LI>\r
- <A href="#value">value</A>\r
- <LI>\r
- <A href="#type-tag">type-tag</A>\r
- <LI>\r
- <A href="#type-spec">type-spec</A>\r
- <LI>\r
- <A href="#method-call-flags">method-call-flags</A>\r
- <LI>\r
- <A href="#method-response-flags">method-response-flags</A>\r
- <LI>\r
- <A href="#return-type-tag">return-type-tag</A>\r
- <LI>\r
- <A href="#primitive-type-code">primitive-type-code</A></LI></UL>\r
- </UL>\r
- <a name="intro"></a>\r
- <H2>Introduction</H2>\r
- <P>This document describes the format used by the class BinaryFormatter to \r
- serialize object graphs. The document is based on the analysis of the output of \r
- the BinaryFormatter of the Microsoft .NET runtime, so it is probably not \r
- complete, since I cannot be sure that I have tested all cases. In fact, there \r
- are some gaps in some tables of codes, so if you find a meaning for the missing \r
- codes, please contact me and I'll update the document.</P>\r
- <a name="format"></a>\r
- <H2>Format description</H2>\r
- <P>An object serialization is a sequence of binary elements. A binary element \r
- coluld be for example a description of an object, an array, an assembly, etc. \r
- Each binary element has a specific format, which is described in the following \r
- sections.</P>\r
- <P>This table shows the available binary elements:</P>\r
- <P>\r
- <TABLE id="Table1" style="WIDTH: 560px; HEIGHT: 94px" cellSpacing="1" cellPadding="1" width="560" border="1">\r
- <TR>\r
- <TD width="40"><STRONG>Code</STRONG></TD>\r
- <TD><STRONG>Label</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">0</TD>\r
- <TD>Header</TD>\r
- <TD>Allways written at the beggining of a serialization</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">1</TD>\r
- <TD><A href="#elem1">RefTypeObject</A></TD>\r
- <TD>Object with no type metadata</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">4</TD>\r
- <TD><A href="#elem4">RuntimeObject</A></TD>\r
- <TD>Corlib object</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">5</TD>\r
- <TD><A href="#elem5">ExternalObject</A></TD>\r
- <TD>Object</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">6</TD>\r
- <TD><A href="#elem6">String</A></TD>\r
- <TD>String</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">7</TD>\r
- <TD><A href="#elem7">GenericArray</A></TD>\r
- <TD>Array</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">8</TD>\r
- <TD><A href="#elem8">BoxedPrimitiveTypeValue</A></TD>\r
- <TD>Primitive type value</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">9</TD>\r
- <TD><A href="#elem9">ObjectReference</A></TD>\r
- <TD>Object reference</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">10</TD>\r
- <TD><A href="#elem10">NullValue</A></TD>\r
- <TD>Null value</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">11</TD>\r
- <TD><A href="#elem11">End</A></TD>\r
- <TD>End of stream</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">12</TD>\r
- <TD><A href="#elem12">Assembly</A></TD>\r
- <TD>Assembly declaration</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">13</TD>\r
- <TD><A href="#elem13">ArrayFiller8b</A></TD>\r
- <TD>Null filler (8 bit length)</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">14</TD>\r
- <TD><A href="#elem14">ArrayFiller32b</A></TD>\r
- <TD>Null filler (16 bit length)</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">15</TD>\r
- <TD><A href="#elem15">ArrayOfPrimitiveType</A></TD>\r
- <TD>Array of primitive type</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">16</TD>\r
- <TD><A href="#elem16">ArrayOfObject</A></TD>\r
- <TD>Array of Object</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">17</TD>\r
- <TD><A href="#elem17">ArrayOfString</A></TD>\r
- <TD>Array of string</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">21</TD>\r
- <TD><A href="#elem21">MethodCall</A></TD>\r
- <TD>Method call</TD>\r
- </TR>\r
- <TR>\r
- <TD width="40">22</TD>\r
- <TD><A href="#elem22">MethodResponse</A></TD>\r
- <TD>Method response</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <P>All elements begin with a byte that identifies the type of element. It is shown \r
- in the "Code" column. In the implementation of the formatter I use an enum to \r
- represent those codes. The "Label" column is the name of the corresponding enum \r
- element.</P>\r
- <a name="example"></a>\r
- <H3>An example</H3>\r
- <P>The best way to underestand the format is to look at an example. Let's see how \r
- the following structure of classes would be serialized:</P>\r
- <BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">\r
- <P><FONT face="Courier New">class A<BR>\r
- {<BR>\r
- B bval = new B();<BR>\r
- C cval = new C();<BR>\r
- string msg = "hello";<BR>\r
- }<BR>\r
- <BR>\r
- class B<BR>\r
- {<BR>\r
- string str = "bye";<BR>\r
- }<BR>\r
- <BR>\r
- struct C<BR>\r
- {<BR>\r
- string[] info = new string[] {"hello","world"}<BR>\r
- }</FONT></P>\r
- </BLOCKQUOTE>\r
- <P>The serialization of an instance of class A would result in a sequence of binary \r
- elements like the following:</P>\r
- <P>\r
- <TABLE id="Table35" cellSpacing="1" cellPadding="1" width="100%" border="1">\r
- <TR>\r
- <TD vAlign="top" width="169"><STRONG>Element</STRONG></TD>\r
- <TD vAlign="top" width="40"><STRONG>Bytes</STRONG></TD>\r
- <TD vAlign="top" width="186"><STRONG>Data</STRONG></TD>\r
- <TD vAlign="top"><STRONG>Comments</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169">Header</TD>\r
- <TD vAlign="top" width="40">0<BR>\r
- 1,0,0,0,<BR>\r
- 255,255,255,255,<BR>\r
- 1,0,0,0,0,0,0,0</TD>\r
- <TD vAlign="top" width="186">Element code ?</TD>\r
- <TD vAlign="top">This sequence of bytes is serialized at the beginning. I'm sure it \r
- has a meaning, but I don't know it.</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"><A href="#elem12">Assembly</A></TD>\r
- <TD vAlign="top" width="40">1<BR>\r
- 1,0,0,0<BR>\r
- "MyAssembly"</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- ID of the assembly (1)<BR>\r
- Full name of the assembly</TD>\r
- <TD vAlign="top">\r
- <P>Before serializing an object, the assembly where the object is implemented has \r
- to be serialized. The formatter assigns an ID to the assembly (ID 1 in this \r
- case). This ID will by used to refer to this assembly.</P>\r
- </TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"><A href="#elem5">ExternalObject</A></TD>\r
- <TD vAlign="top" width="40">5<BR>\r
- 2,0,0,0<BR>\r
- "A"<BR>\r
- 3,0,0,0<BR>\r
- "bval","cval","msg"<BR>\r
- 4,4,1<BR>\r
- "B"<BR>\r
- 1,0,0,0<BR>\r
- "C"<BR>\r
- 1,0,0,0<BR>\r
- 1,0,0,0</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- Object ID (2)<BR>\r
- Class name<BR>\r
- Field count<BR>\r
- Field names<BR>\r
- Field type tags<BR>\r
- Class name of field "bval"<BR>\r
- Assembly ID of field "bval"<BR>\r
- Class name of field "cval"<BR>\r
- Assembly ID of field "cval"<BR>\r
- Assembly ID of this object</TD>\r
- <TD vAlign="top">Serialization of the root object. Each object has an ID that is \r
- used, for example, to specify object relations. The object binary element has \r
- two parts. The first one is type metadata: the name and type of serialized \r
- fields. The second part is the object data: field values. The data part is \r
- shown in the following nested elements.</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"> <A href="#elem9">ObjectReference</A></TD>\r
- <TD vAlign="top" width="40">9<BR>\r
- 5,0,0,0</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- ID of the referred object (5)</TD>\r
- <TD vAlign="top">Reference objects are not serialized inside the container element. \r
- Instead, an ObjectReference is serialized, and the object itself queued for \r
- later serialization.</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"> <A href="#elem5">ExternalObject</A></TD>\r
- <TD vAlign="top" width="40">5<BR>\r
- 3,0,0,0<BR>\r
- C<BR>\r
- 1,0,0,0<BR>\r
- "info"<BR>\r
- 6<BR>\r
- 1,0,0,0</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- Object ID (3)<BR>\r
- Class name<BR>\r
- Field count<BR>\r
- Field name<BR>\r
- Field type tag<BR>\r
- Assembly ID of this object</TD>\r
- <TD vAlign="top">On the other hand, value type objects are serialized inside the \r
- container element.</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"> \r
- <A href="#elem9">ObjectReference</A></TD>\r
- <TD vAlign="top" width="40">9<BR>\r
- 7,0,0,0</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- ID of the referred object (7)</TD>\r
- <TD vAlign="top">This is again a reference object, so it is serialized later.</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"> <A href="#elem6">String</A></TD>\r
- <TD vAlign="top" width="40">6<BR>\r
- 4,0,0,0<BR>\r
- "hello"</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- Object ID (4)<BR>\r
- String value</TD>\r
- <TD vAlign="top">Strings are serialized like value objects</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"><A href="#elem5">ExternalObject</A></TD>\r
- <TD vAlign="top" width="40">5<BR>\r
- 5,0,0,0<BR>\r
- "B"<BR>\r
- 1,0,0,0<BR>\r
- "str"<BR>\r
- 1<BR>\r
- 1,0,0,0</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- Object ID (5)<BR>\r
- Class name<BR>\r
- Field count<BR>\r
- Field name<BR>\r
- Field type tag<BR>\r
- Assembly ID of this object</TD>\r
- <TD vAlign="top">\r
- <P>Reference objects queued for serialization are serialized after the root object.</P>\r
- </TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"> <A href="#elem6">String</A></TD>\r
- <TD vAlign="top" width="40">6<BR>\r
- 6,0,0,0<BR>\r
- "bye"</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- Object ID (6)<BR>\r
- String value</TD>\r
- <TD vAlign="top">A string</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"><A href="#elem17">ArrayOfString</A></TD>\r
- <TD vAlign="top" width="40">17<BR>\r
- 7,0,0,0<BR>\r
- 2,0,0,0</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- Object ID (7)<BR>\r
- Element count</TD>\r
- <TD vAlign="top">This could be also encoded using the binary element Array \r
- (7), but ArrayOfString is more specific and saves bytes.</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"> <A href="#elem9">ObjectReference</A></TD>\r
- <TD vAlign="top" width="40">9<BR>\r
- 4,0,0,0</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- ID of the referred object (4)</TD>\r
- <TD vAlign="top">This string was already serialized. Use a backwards reference.</TD>\r
- </TR>\r
- <TR>\r
- <TD vAlign="top" width="169"> <A href="#elem6">String</A></TD>\r
- <TD vAlign="top" width="40">6<BR>\r
- 8,0,0,0<BR>\r
- "world"</TD>\r
- <TD vAlign="top" width="186">Element code<BR>\r
- Object ID (8)<BR>\r
- String value</TD>\r
- <TD vAlign="top">Another string</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elements"></a>\r
- <H2>Binary elements</H2>\r
- <P>The following sections show the format of each binary element. The format is \r
- presented in a table with two columns. The first one shows the sequence of \r
- bytes and the second one a description of each element in the sequence.</P>\r
- <P>A special notation is used to represent the bytes. Here are some examples:</P>\r
- <P>\r
- <TABLE id="Table36" style="WIDTH: 448px; HEIGHT: 129px" cellSpacing="1" cellPadding="1" width="448" border="1">\r
- <TR>\r
- <TD width="193"><STRONG>Example of element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="193">(byte) 7</TD>\r
- <TD>A single byte</TD>\r
- </TR>\r
- <TR>\r
- <TD width="193">uint</TD>\r
- <TD>Any uint value (4 bytes)</TD>\r
- </TR>\r
- <TR>\r
- <TD width="193"><EM><A href="#type-tag">type-tag</A></EM></TD>\r
- <TD>Names in italic are described in the section "Other elements"</TD>\r
- </TR>\r
- <TR>\r
- <TD width="193"><EM><A href="#string">string</A></EM> *</TD>\r
- <TD>* represents a sequence of elements</TD>\r
- </TR>\r
- <TR>\r
- <TD width="193">object</TD>\r
- <TD>Full serialization of an object</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem1"></a>\r
- <H3>1 - RefTypeObject\r
- </H3>\r
- <P>An object is serialized in two parts. The first one is type metadata, and the \r
- second one is the object data. When several objects of the same type are \r
- serialized, only the first one has the metadata part. The other objects are \r
- serialized using the RefTypeObject element, which instead of the metadata, it \r
- includes an ID of an object that is of the same type as the one being \r
- serialized.</P>\r
- <P>\r
- <TABLE id="Table2" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 1</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Object ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>ID of a previously serialized object from which to take type metadata.</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#value">value</A> </EM>*</TD>\r
- <TD>Values of the fields of the object</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem4"></a>\r
- <H3>4 - RuntimeObject</H3>\r
- <P>This element is used to serialize objects of types that are implemented in the \r
- core library of the framework. The only difference from the format for other \r
- objects if that it does not include assembly information, which is not needed \r
- since the assembly will always be mscorlib.</P>\r
- <P>\r
- <TABLE id="Table21" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 4</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Object ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#string">string</A></EM></TD>\r
- <TD>Class name, including namespace</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Number of serialized fields</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#string">string</A> </EM>*</TD>\r
- <TD>Names of the fields</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#type-tag">type-tag</A> *</EM></TD>\r
- <TD>type-tag of each field</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#type-spec">type-spec</A> *</EM></TD>\r
- <TD>type-spec of each field</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#value">value</A> *</EM></TD>\r
- <TD>Values of the fields of the object</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem5"></a>\r
- <H3>5 - ExternalObject</H3>\r
- <P>This element can be used to serialize any object from any assembly.</P>\r
- <H3>\r
- <TABLE id="Table22" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 5</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Object ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#string">string</A></EM></TD>\r
- <TD>Class name, including namespace</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Number of serialized fields</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#string">string</A> </EM>*</TD>\r
- <TD>Names of the fields</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#type-tag">type-tag</A> </EM>*</TD>\r
- <TD>type-tag of each field</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#type-spec">type-spec</A> </EM>*</TD>\r
- <TD>type-spec of each field</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>ID of the assembly where the class is defined (the assembly must have been \r
- serialized before the class using the binary element 12)</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#value">value</A> </EM>*</TD>\r
- <TD>Values of the fields of the object</TD>\r
- </TR>\r
- </TABLE>\r
- </H3>\r
- <a name="elem6"></a>\r
- <H3>6 - String</H3>\r
- <P>A string value.</P>\r
- <P>\r
- <TABLE id="Table23" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 6</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Object ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#string">string</A></EM></TD>\r
- <TD>Value of the string</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem7"></a>\r
- <H3>7 - GenericArray</H3>\r
- <P>This element can be used to represent any array.</P>\r
- <H3>\r
- <TABLE id="Table24" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 7</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Object ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">byte</TD>\r
- <TD>Array type: 0:single dimension, 1: jagged, 2: multi-dimensional</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Number of dimensions (rank)</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint *</TD>\r
- <TD>Number of elements for each dimension</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#type-tag">type-tag</A></EM></TD>\r
- <TD>type-tag of array's element type</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#type-spec">type-spec</A></EM></TD>\r
- <TD>type-spec of array's element type</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#value">value</A> *</EM></TD>\r
- <TD>Values of the elements, row by row</TD>\r
- </TR>\r
- </TABLE>\r
- </H3>\r
- <a name="elem8"></a>\r
- <H3>8 - BoxedPrimitiveTypeValue</H3>\r
- <P>This element represents a primitive type value boxed as an object.</P>\r
- <P>\r
- <TABLE id="Table25" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 8</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#type-spec">type-spec</A></EM></TD>\r
- <TD>type-spec of the primitive type</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#primitive-value">primitive-value</A></EM></TD>\r
- <TD>Raw value</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem9"></a>\r
- <H3>9 - ObjectReference</H3>\r
- <P>This element represents a reference to an object already serialized (backwards \r
- reference) or that will be serialized later (forward reference).\r
- </P>\r
- <P>\r
- <TABLE id="Table26" style="WIDTH: 568px; HEIGHT: 16px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 9</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>ID of the referred object</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem10"></a>\r
- <H3>10 - NullValue</H3>\r
- <P>A null value.</P>\r
- <TABLE id="Table27" style="WIDTH: 568px; HEIGHT: 16px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 10</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- </TABLE>\r
- <P></P>\r
- <a name="elem11"></a>\r
- <H3>\r
- <P>11 - End</P>\r
- </H3>\r
- <P>This element marks the end of the serialized object graph.</P>\r
- <TABLE id="Table28" style="WIDTH: 568px; HEIGHT: 16px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 11</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- </TABLE>\r
- <a name="elem12"></a>\r
- <H3>\r
- <P>12 - Assembly</P>\r
- </H3>\r
- <P>Defines an assembly. Each assembly is defined only once and has an ID. This ID \r
- is used when serializing an object (element 5) to specify the assembly where \r
- object's type is implemented.</P>\r
- <TABLE id="Table29" style="WIDTH: 568px; HEIGHT: 16px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 12</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Assembly ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#string">string</A></EM></TD>\r
- <TD>Full name of the assembly</TD>\r
- </TR>\r
- </TABLE>\r
- <a name="elem13"></a>\r
- <H3>\r
- <P>13 - ArrayFiller8b</P>\r
- </H3>\r
- <P>This element can be used when serializing array data to specify multiple \r
- consecutive null values. It it only used in single dimension arrays of \r
- reference objects (not valid for value-type objects).</P>\r
- <TABLE id="Table30" style="WIDTH: 568px; HEIGHT: 16px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 13</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">byte</TD>\r
- <TD>Number of consecutive null values</TD>\r
- </TR>\r
- </TABLE>\r
- <P></P>\r
- <a name="elem14"></a>\r
- <H3>\r
- <P>14 - ArrayFiller32b</P>\r
- </H3>\r
- <P>The same as ArrayFiller8b, but it uses a uint to specify the length.</P>\r
- <TABLE id="Table31" style="WIDTH: 568px; HEIGHT: 16px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 14</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Number of consecutive null values</TD>\r
- </TR>\r
- </TABLE>\r
- <P></P>\r
- <a name="elem15"></a>\r
- <H3>\r
- <P>15 - ArrayOfPrimitiveType</P>\r
- </H3>\r
- <P>This element can be used to represent a single dimension array of primitive type \r
- values.</P>\r
- <P>\r
- <TABLE id="Table32" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 15</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Object ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Number of elements</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#type-spec">type-spec</A></EM></TD>\r
- <TD>type-spec of array's element type</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#primitive-value">primitie-value</A> *</EM></TD>\r
- <TD>Values of the elements</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem16"></a>\r
- <H3>16 - ArrayOfObject</H3>\r
- <P>This element can be used to represent a single dimension array of Object (i.e. \r
- an object[] ).</P>\r
- <P>\r
- <TABLE id="Table33" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 16</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Object ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Number of elements</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">object *</TD>\r
- <TD>Values of the elements</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem17"></a>\r
- <H3>17 - ArrayOfString</H3>\r
- <P>This element can be used to represent a single dimension array of String \r
- (i.e. an string[] ).</P>\r
- <P>\r
- <TABLE id="Table34" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 17</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Object ID</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">uint</TD>\r
- <TD>Number of elements</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">object *</TD>\r
- <TD>Values of the elements</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="elem21"></a>\r
- <H3>21 Method call</H3>\r
- <P>Represents a method call. The format of a method call can vary depending on the \r
- type of the parameters. The following table shows the common format:</P>\r
- <P>\r
- <TABLE id="Table20" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(byte) 21</TD>\r
- <TD>Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#method-call-flags">method-call-flags (int32)</A></EM></TD>\r
- <TD>Describes wich information includes the method call</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><EM><A href="#type-spec">type-spec</A><BR>\r
- <EM><A href="#primitive-value">primitive-value</A></EM></EM></EM></TD>\r
- <TD>Method name</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><EM><EM><A href="#type-spec">type-spec</A><BR>\r
- <EM><A href="#primitive-value">primitive-value</A></EM></EM></EM></EM></TD>\r
- <TD>Class name (including namespace and assembly)</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <P>The following tables describe the format of the message content depending on the \r
- value of method-call-flags:</P>\r
- <H4>method-call-flags & NoArguments</H4>\r
- <P>Used for calls to methods without parameters.</P>\r
- <H4>\r
- <TABLE id="Table8" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="119"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">Header[]</TD>\r
- <TD>Only if there are Headers and method-call-flags has the flag <EM>IncludeLogicalCallContext.\r
- </EM>Headers are serialized only if there is context info. This must be a bug \r
- in MS.NET.</TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">object[]</TD>\r
- <TD>\r
- <P>Array with the following values:</P>\r
- <UL>\r
- <li>Generic arguments if the method is generic and method-call-flags has the flag GenericArguments (NET_2_0).</li>\r
- <LI>\r
- Method signature, only if method-call-flags has the flag IncludesSignature. It \r
- is an array of Type.\r
- <LI>\r
- LogicalCallContext instance, only if method-call-flags has the flag \r
- IncludesLogicalCallContext.</LI></UL>\r
- <P>If the array is empty, it is not serialized.</P>\r
- </TD>\r
- </TR>\r
- </TABLE>\r
- </H4>\r
- <H4>method-call-flags & PrimitiveArguments</H4>\r
- <P>Used for calls to methods in which all parameters are primitive types.</P>\r
- <P>\r
- <TABLE id="Table5" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="119"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">uint</TD>\r
- <TD>Number of parameters</TD>\r
- </TR>\r
- <TR>\r
- <TD width="119"><EM><EM><EM><EM>( <A href="#type-spec">type-spec</A></EM></EM></EM><BR>\r
- <A href="#primitive-value">primitive-value</A> ) *</EM></TD>\r
- <TD>One value for each parameter</TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">Header[]</TD>\r
- <TD>Only if there are Headers and method-response-flags has the flag <EM>IncludeLogicalCallContext.\r
- </EM>Headers are serialized only if there is context info. This must be a bug \r
- in MS.NET.</TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">object[]</TD>\r
- <TD>\r
- <P>Array with the following values:</P>\r
- <UL>\r
- <li>Generic arguments if the method is generic and method-call-flags has the flag GenericArguments (NET_2_0).</li>\r
- <LI>\r
- Method signature, only if method-call-flags has the flag IncludesSignature. It \r
- is an array of Type.\r
- <LI>\r
- LogicalCallContext instance, only if method-call-flags has the flag \r
- IncludesLogicalCallContext.</LI></UL>\r
- <P>If the array is empty, it is not serialized.</P>\r
- </TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <H4>method-call-flags & ArgumentsInSimpleArray</H4>\r
- <P>Used for calls to methods in which at least one parameter is not a primitive \r
- type, and when no other info needs to be serialized (i.e. context or \r
- signature).</P>\r
- <P>\r
- <TABLE id="Table6" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="119"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">Header[]</TD>\r
- <TD>Only if there are Headers.</TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">object[]</TD>\r
- <TD>\r
- <P>Array of parameters.\r
- </P>\r
- </TD>\r
- </TR>\r
- </TABLE>\r
- <H4>method-call-flags & ArgumentsInMultiArray</H4>\r
- <P>Used for calls to methods in which at least one parameter is not a primitive \r
- type, and when other info needs to be serialized (i.e. context or signature).</P>\r
- <P>\r
- <TABLE id="Table7" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="119"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">Header[]</TD>\r
- <TD>Only if there are Headers.</TD>\r
- </TR>\r
- <TR>\r
- <TD width="119">object[]</TD>\r
- <TD>\r
- <P>\r
- Array with the following values:</P>\r
- <UL>\r
- <LI>\r
- Array of parameters.\r
- <li>Generic arguments if the method is generic and method-call-flags has the flag GenericArguments (NET_2_0).</li>\r
- <LI>\r
- Method signature, only if method-call-flags has the flag IncludesSignature. It \r
- is an array of Type.\r
- <LI>\r
- LogicalCallContext instance, only if method-call-flags has the flag \r
- IncludesLogicalCallContext.</LI></UL>\r
- <P>\r
- If the array is empty, it is not serialized.</P>\r
- </TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- </TD></TR></TBODY></TABLE> <a name="elem22"></a>\r
- <H3>22 Method Response</H3>\r
- <P>Represents a method response. The format of a method response can vary depending \r
- on the type of the return value and parameters. The following table \r
- shows the common format:</P>\r
- <P>\r
- <TABLE id="Table9" style="WIDTH: 568px; HEIGHT: 140px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="142"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="142" height="25">(byte) 22</TD>\r
- <TD height="25">Element code</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#method-response-flags">method-response-flags</A></EM></TD>\r
- <TD>Describes which information includes the method call</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142"><EM><A href="#return-type-tag">return-type-tag</A></EM></TD>\r
- <TD>Describes which kind of value is returned</TD>\r
- </TR>\r
- <TR>\r
- <TD width="142">(bytes) 0, 0</TD>\r
- <TD>???</TD>\r
- </TR>\r
- </TABLE>\r
- <P></P>\r
- <P>The following tables describe the format of the message content depending on the \r
- value of method-response-flags:</P>\r
- <H4>method-response-flags & NoArguments</H4>\r
- <P>Used when the method has no out arguments.</P>\r
- <P>\r
- <TABLE id="Table10" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="139"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="139"><EM><EM><EM><A href="#type-spec">type-spec</A><BR>\r
- <EM><A href="#primitive-value">primitive-value</A></EM></EM></EM></EM></TD>\r
- <TD>\r
- <P><EM>Only if return-type-tag was PrimitiveType.<BR>\r
- </EM>Return value.</P>\r
- </TD>\r
- </TR>\r
- <TR>\r
- <TD width="139">Header[]</TD>\r
- <TD>Only if there are Headers.</TD>\r
- </TR>\r
- <TR>\r
- <TD width="139">object[]</TD>\r
- <TD>\r
- <P>Array with the following values:</P>\r
- <UL>\r
- <LI>\r
- Return value, only if <EM>return-type-tag</EM> was <EM>ObjectType</EM>\r
- <LI>\r
- LogicalCallContext instance, only if method-response-flags has the flag \r
- IncludeLogicalCallContext</LI></UL>\r
- <P>If the array is empty, it is not serialized.</P>\r
- </TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <H4>method-response-flags & PrimitiveArguments</H4>\r
- <P>Used when all out arguments are primitive types.</P>\r
- <H2>\r
- <TABLE id="Table12" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="139"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="139"><EM><EM><EM><A href="#type-spec">type-spec</A><BR>\r
- <EM><A href="#primitive-value">primitive-value</A></EM></EM></EM></EM></TD>\r
- <TD>\r
- <P><EM>Only if return-type-tag was PrimitiveType.<BR>\r
- </EM>Return value.</P>\r
- </TD>\r
- </TR>\r
- <TR>\r
- <TD width="139">uint</TD>\r
- <TD>Number of out arguments</TD>\r
- </TR>\r
- <TR>\r
- <TD width="139"><EM><EM><EM>( <A href="#type-spec">type-spec</A>\r
- <BR>\r
- <EM><A href="#primitive-value">primitive-value</A> )</EM></EM></EM> *</EM></TD>\r
- <TD>One value for each argument</TD>\r
- </TR>\r
- <TR>\r
- <TD width="139">Header[]</TD>\r
- <TD>Only if there are Headers. Empty otherwise.</TD>\r
- </TR>\r
- <TR>\r
- <TD width="139">object[]</TD>\r
- <TD>\r
- <P>Array with the following values:</P>\r
- <UL>\r
- <LI>\r
- Return value, only if <EM>return-type-tag</EM> was <EM>ObjectType</EM>\r
- <LI>\r
- LogicalCallContext instance, only if method-response-flags has the flag \r
- IncludeLogicalCallContext</LI></UL>\r
- <P>If the array is empty, it is not serialized.</P>\r
- </TD>\r
- </TR>\r
- </TABLE>\r
- </H2>\r
- <H4>method-response-flags & ArgumentsInSimpleArray</H4>\r
- <P>Used when at least one out argument is not a primitive type, return type is \r
- primitive, and no other info needs to be serialized.</P>\r
- <H2>\r
- <TABLE id="Table13" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="140"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="140"><EM><EM><EM><A href="#type-spec">type-spec</A><BR>\r
- <EM><A href="#primitive-value">primitive-value</A></EM></EM></EM></EM></TD>\r
- <TD>\r
- <P><EM>Only if return-type-tag was PrimitiveType.<BR>\r
- </EM>Return value.</P>\r
- </TD>\r
- </TR>\r
- <TR>\r
- <TD width="140">Header[]</TD>\r
- <TD>Only if there are Headers.</TD>\r
- </TR>\r
- <TR>\r
- <TD width="140">object[]</TD>\r
- <TD>Array that contains the out arguments</TD>\r
- </TR>\r
- </TABLE>\r
- </H2>\r
- <H4>method-response-flags & ArgumentsInMultiArray</H4>\r
- <P>Used when at least one out argument is not a primitive type, return type is not \r
- primitive, and no other info needs to be serialized.</P>\r
- <H2>\r
- <TABLE id="Table14" style="WIDTH: 568px; HEIGHT: 75px" cellSpacing="1" cellPadding="1" width="568" border="1">\r
- <TR>\r
- <TD width="141"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="141"><EM><EM><EM><A href="#type-spec">type-spec</A><BR>\r
- <EM><A href="#primitive-value">primitive-value</A></EM></EM></EM></EM></TD>\r
- <TD>\r
- <P>Only if <EM>return-type-tag </EM>was <EM>PrimitiveType.<BR>\r
- </EM>Return value.</P>\r
- </TD>\r
- </TR>\r
- <TR>\r
- <TD width="141">Header[]</TD>\r
- <TD>Only if there are Headers</TD>\r
- </TR>\r
- <TR>\r
- <TD width="141">object[]</TD>\r
- <TD>\r
- <P>Array with the following values:</P>\r
- <UL>\r
- <LI>\r
- Array of out arguments.\r
- <LI>\r
- Return value, only if <EM>return-type-tag</EM> was <EM>ObjectType</EM>\r
- <LI>\r
- LogicalCallContext instance, only if method-response-flags has the flag \r
- IncludeLogicalCallContext</LI></UL>\r
- </TD>\r
- </TR>\r
- </TABLE>\r
- </H2>\r
- <a name="other"></a>\r
- <H2>Other elements</H2>\r
- <a name="string"></a>\r
- <H3>string</H3>\r
- <P>A string value, serialized using BinaryWriter. It serializes the length of the \r
- string, using a 7-bit encoded int, and then the string chars.</P>\r
- <a name="primitive-value"></a>\r
- <H3>primitive-value</H3>\r
- <P>A primitive value. It can be serialized using BinaryWriter and deserialized \r
- using BinaryReader. DateTime is serialized as a long (using the Ticks \r
- property).\r
- </P>\r
- <a name="value"></a>\r
- <H3>value</H3>\r
- <P>It can be a <A href="#primitive-value">primitive-value</A> or any of the \r
- following binary elements:</P>\r
- <UL>\r
- <LI>\r
- <A href="#elem1">1 - RefTypeObject</A>\r
- (only for value types)\r
- <LI>\r
- <A href="#elem4">4 - RuntimeObject</A>\r
- (only for value types)\r
- <LI>\r
- <A href="#elem5">5 - ExternalObject</A> (only for value types)\r
- <LI>\r
- <A href="#elem6">6 - String</A>\r
- <LI>\r
- <A href="#elem8">8 - BoxedPrimitiveTypeValue</A>\r
- <LI>\r
- <A href="#elem9">9 - ObjectReference</A>\r
- <LI>\r
- <A href="#elem10">10 - NullValue</A>\r
- <LI>\r
- <A href="#elem13">13 - ArrayFiller8b</A> (only inside \r
- single-dimensional object arrays)\r
- <LI>\r
- <A href="#elem14">14 - ArrayFiller32b</A> (only inside single-dimensional \r
- object arrays)</LI></UL>\r
- <a name="type-tag"></a>\r
- <H3>type-tag</H3>\r
- <P>Together with a <A href="#type-spec">type-spec</A> value, identifies a type. \r
- Some types can be represented using several type-tags. In this case, the most \r
- specific type-tag is allways used (it will take less bytes).</P>\r
- <P>type-tag can be one of the following:</P>\r
- <P>\r
- <TABLE id="Table18" cellSpacing="1" cellPadding="1" width="600" border="1">\r
- <TR>\r
- <TD><STRONG>Value</STRONG></TD>\r
- <TD><STRONG>Label</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- <TD><STRONG>type-spec needed</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD>0</TD>\r
- <TD>PrimitiveType</TD>\r
- <TD>A primitive type</TD>\r
- <TD>The code of the primitive type</TD>\r
- </TR>\r
- <TR>\r
- <TD>1</TD>\r
- <TD>String</TD>\r
- <TD>String class. type-spec is not needed.</TD>\r
- <TD>Not needed</TD>\r
- </TR>\r
- <TR>\r
- <TD>2</TD>\r
- <TD>ObjectType</TD>\r
- <TD>Object class. type-spec is not needed.</TD>\r
- <TD>Not needed</TD>\r
- </TR>\r
- <TR>\r
- <TD height="20">3</TD>\r
- <TD height="20">RuntimeType</TD>\r
- <TD height="20">A type from the .NET runtime (including arrays of .NET types)</TD>\r
- <TD height="20">The name of the class</TD>\r
- </TR>\r
- <TR>\r
- <TD>4</TD>\r
- <TD>GenericType</TD>\r
- <TD>Any other type (including arrays)</TD>\r
- <TD>The name of the class and the id of the assembly</TD>\r
- </TR>\r
- <TR>\r
- <TD>5</TD>\r
- <TD>ArrayOfObject</TD>\r
- <TD>Array of class Object</TD>\r
- <TD>Not needed</TD>\r
- </TR>\r
- <TR>\r
- <TD>6</TD>\r
- <TD>ArrayOfString</TD>\r
- <TD>Array of class String</TD>\r
- <TD>Not needed</TD>\r
- </TR>\r
- <TR>\r
- <TD>7</TD>\r
- <TD>ArrayOfPrimitiveType</TD>\r
- <TD>Array of primitive type</TD>\r
- <TD>The code of the primitive type</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="type-spec"></a>\r
- <H3>type-spec</H3>\r
- <P>It is the name or the code of a type. To decode it, a <A href="#type-tag">type-tag</A>\r
- value is needed. The following tables shows the format of type-spec for each \r
- type-tag value:</P>\r
- <H4>type-tag = PrimitiveType or ArrayOfPrimitiveType</H4>\r
- <P>\r
- <TABLE id="Table16" style="WIDTH: 560px; HEIGHT: 14px" cellSpacing="1" cellPadding="1" width="560" border="1">\r
- <TR>\r
- <TD width="119"><STRONG>Element</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="119"><A href="#primitive-type-code">primitive-type-code</A></TD>\r
- <TD>\r
- The code of the primitive type</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <H4>type-tag = RuntimeType</H4>\r
- <P>\r
- <TABLE id="Table15" style="WIDTH: 560px; HEIGHT: 14px" cellSpacing="1" cellPadding="1" width="560" border="1">\r
- <TR>\r
- <TD><STRONG><STRONG>Element</STRONG></STRONG></TD>\r
- <TD><STRONG><STRONG>Description</STRONG></STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD><EM><A href="#string">string</A></EM></TD>\r
- <TD>The name of the class, including the namespace</TD>\r
- </TR>\r
- </TABLE>\r
- <H4>type-tag = GenericType</H4>\r
- <P>\r
- <TABLE id="Table17" style="WIDTH: 560px; HEIGHT: 14px" cellSpacing="1" cellPadding="1" width="560" border="1">\r
- <TR>\r
- <TD><STRONG>Element</STRONG></TD>\r
- <TD><STRONG><STRONG>Description</STRONG></STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD><EM><A href="#string">string</A></EM></TD>\r
- <TD>The name of the class, including the namespace</TD>\r
- </TR>\r
- <TR>\r
- <TD>uint</TD>\r
- <TD>Id of the assembly where the class is defined</TD>\r
- </TR>\r
- </TABLE>\r
- <H3>\r
- <H4>Other type-tag</H4>\r
- </H3>\r
- <P>For other type-tag values, no type-spec is needed.</P>\r
- <a name="method-call-flags"></a>\r
- <H3>method-call-flags</H3>\r
- <P>\r
- <TABLE id="Table3" cellSpacing="1" cellPadding="1" width="600" border="1">\r
- <TR>\r
- <TD><STRONG>Value</STRONG></TD>\r
- <TD><STRONG>Label</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD>1</TD>\r
- <TD>NoArguments</TD>\r
- <TD>No arguments included</TD>\r
- </TR>\r
- <TR>\r
- <TD>2</TD>\r
- <TD>PrimitiveArguments</TD>\r
- <TD>Primitive type arguments</TD>\r
- </TR>\r
- <TR>\r
- <TD>4</TD>\r
- <TD>ArgumentsInSimpleArray</TD>\r
- <TD>At least one out argument is not from a primitive type</TD>\r
- </TR>\r
- <TR>\r
- <TD height="20">8</TD>\r
- <TD height="20">ArgumentsInMultiArray</TD>\r
- <TD height="20">At least one out argument is not from a primitive type and other \r
- info is included in the message (context or signature)</TD>\r
- </TR>\r
- <TR>\r
- <TD>16</TD>\r
- <TD>ExcludeLogicalCallContext</TD>\r
- <TD>LogicalContext not included</TD>\r
- </TR>\r
- <TR>\r
- <TD>32</TD>\r
- <TD></TD>\r
- <TD>???</TD>\r
- </TR>\r
- <TR>\r
- <TD>64</TD>\r
- <TD>IncludesLogicalCallContext</TD>\r
- <TD>LogicalContext included</TD>\r
- </TR>\r
- <TR>\r
- <TD>128</TD>\r
- <TD>IncludesSignature</TD>\r
- <TD>Signature is included in the message. It is only included when calling an \r
- overloaded method.</TD>\r
- </TR>\r
- \r
- <TR>\r
- <TD>32768 (0x8000)</TD>\r
- <TD>GenericArguments</TD>\r
- <TD>Generic arguments are included in the message (NET_2_0).</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="method-response-flags"></a>\r
- <H3>method-response-flags</H3>\r
- <P>\r
- <TABLE id="Table4" cellSpacing="1" cellPadding="1" width="600" border="1">\r
- <TR>\r
- <TD><STRONG>Value</STRONG></TD>\r
- <TD width="190"><STRONG>Label</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD>1</TD>\r
- <TD width="190">NoArguments</TD>\r
- <TD>Response with no out arguments</TD>\r
- </TR>\r
- <TR>\r
- <TD>2</TD>\r
- <TD width="190">PrimitiveArguments</TD>\r
- <TD>\r
- Response with primitive type out arguments</TD>\r
- </TR>\r
- <TR>\r
- <TD>4</TD>\r
- <TD width="190">ArgumentsInSimpleArray</TD>\r
- <TD>Response with primitive type return value, and with at least one out argument \r
- that is not a primitive type.</TD>\r
- </TR>\r
- <TR>\r
- <TD>8</TD>\r
- <TD width="190">ArgumentsInMultiArray</TD>\r
- <TD>Response with at least one out argument that is not a primitive type, and other \r
- info is included in the message (context or signature)</TD>\r
- </TR>\r
- <TR>\r
- <TD>16</TD>\r
- <TD width="190">ExcludeLogicalCallContext</TD>\r
- <TD>LogicalContext not included</TD>\r
- </TR>\r
- <TR>\r
- <TD>32</TD>\r
- <TD width="190"></TD>\r
- <TD>???</TD>\r
- </TR>\r
- <TR>\r
- <TD>64</TD>\r
- <TD width="190">IncludesLogicalCallContext</TD>\r
- <TD>LogicalContext included</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="return-type-tag"></a>\r
- <H3>return-type-tag</H3>\r
- <P>\r
- <TABLE id="Table11" cellSpacing="1" cellPadding="1" width="600" border="1">\r
- <TR>\r
- <TD><STRONG>Value</STRONG></TD>\r
- <TD><STRONG>Label</STRONG></TD>\r
- <TD><STRONG>Description</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD>2</TD>\r
- <TD>Null</TD>\r
- <TD>Null return value</TD>\r
- </TR>\r
- <TR>\r
- <TD>8</TD>\r
- <TD>PrimitiveType</TD>\r
- <TD>Primitive type return value</TD>\r
- </TR>\r
- <TR>\r
- <TD>16</TD>\r
- <TD>ObjectType</TD>\r
- <TD>Object instance return value</TD>\r
- </TR>\r
- <TR>\r
- <TD>32</TD>\r
- <TD>Exception</TD>\r
- <TD>Method response is an exception</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <a name="primitive-type-code"></a>\r
- <H3>primitive-type-code</H3>\r
- <P>\r
- <TABLE id="Table19" height="171" cellSpacing="1" cellPadding="1" width="320" border="1">\r
- <TR>\r
- <TD width="45"><STRONG>Value</STRONG></TD>\r
- <TD width="190"><STRONG>Label</STRONG></TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">1</TD>\r
- <TD width="190">Boolean\r
- </TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">2</TD>\r
- <TD width="190">Byte</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">3</TD>\r
- <TD width="190">Char</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">5</TD>\r
- <TD width="190">Decimal</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">6</TD>\r
- <TD width="190">Double</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">7</TD>\r
- <TD width="190">Int16</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">8</TD>\r
- <TD width="190">Int32</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">9</TD>\r
- <TD width="190">Int64</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">10</TD>\r
- <TD width="190">SByte</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">11</TD>\r
- <TD width="190">Single</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">13</TD>\r
- <TD width="190">DateTime</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">14</TD>\r
- <TD width="190">UInt16</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">15</TD>\r
- <TD width="190">UInt32</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">16</TD>\r
- <TD width="190">UInt64</TD>\r
- </TR>\r
- <TR>\r
- <TD width="45">18</TD>\r
- <TD width="190">String</TD>\r
- </TR>\r
- </TABLE>\r
- </P>\r
- <HR width="100%" SIZE="1">\r
- <FONT size="1">2003 (C) Lluis Sanchez Gual (</FONT> <A href="mailto:lluis@ideary.com">\r
- <FONT size="1">lluis@ideary.com</FONT></A><FONT size="1">)</FONT>\r
- <P> </P>\r
- </body>\r
-</html>\r
+++ /dev/null
-/IFieldInfo.cs -crlf
-/ISoapMessage.cs -crlf
-/ServerFault.cs -crlf
-/SoapFault.cs -crlf
-/SoapMessage.cs -crlf
+++ /dev/null
-2007-05-03 Dick Porter <dick@ximian.com>
-
- * IFieldInfo.cs:
- * ISoapMessage.cs:
- * InternalRM.cs:
- * InternalST.cs:
- * ServerFault.cs:
- * SoapFault.cs:
- * SoapMessage.cs:
- * FormatterAssemblyStyle.cs:
- * FormatterTypeStyle.cs:
- * TypeFilterLevel.cs: Update to 2.0 profile
-
-2004-06-15 Gert Driesen <drieseng@users.sourceforge.net>
-
- * SoapMessage.cs: fixed serialization compatibility with MS.NET
-
-2003-11-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
-
- * ServerFault.cs: Added missing attribute
- * SoapFault.cs: Added missing attribute
- * InternalRM.cs: Added
- * InternalST.cs: Added
- * TypeFilterLevel.cs: Added (complete)
-
-2003-05-28 Jean-Marc Andre <jean-marc.andre@polymtl.ca>
-
- * SoapFault.cs: finishing implementation
- * ServerFault.cs: finishing implementation
- * SoapMessage.cs: finishing implementation
-
-2002-08-22 Nick Drochak <ndrochak@gol.com>
-
- * SoapFault.cs: Serialization ctr should be private
-
-2002-08-14 Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
-
- * SoapFault.cs: Added the ctr for ISerializable implementation and
- implemented GetObjectData.
-
-2002-07-30 Duncan Mak <duncan@ximian.com>
-
- * ServerFault.cs:
- * SoapFault.cs:
- * SoapMessage.cs: Added missing classes.
-
-2002-01-21 David Dawkins <david@dawkins.st>
-
- * IFieldInfo.cs : New file
- * ISoapMessage.cs : New file
-
+++ /dev/null
-// FormatterAssemblyStyle.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:43:19 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization.Formatters {
-
-
- /// <summary>
- /// </summary>
- [ComVisible (true)]
- [Serializable]
- public enum FormatterAssemblyStyle {
-
- /// <summary>
- /// </summary>
- Simple = 0,
-
- /// <summary>
- /// </summary>
- Full = 1,
- } // FormatterAssemblyStyle
-
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// FormatterTopObjectStyle.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:42:59 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-
-#if ECMA
-
- /// <summary>
- /// </summary>
- public enum FormatterTopObjectStyle {
-
- /// <summary>
- /// </summary>
- Object = 0,
-
- /// <summary>
- /// </summary>
- SoapMessage = 1,
- } // FormatterTopObjectStyle
-#endif
-
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// FormatterTypeStyle.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:43:09 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization.Formatters {
-
-
- /// <summary>
- /// </summary>
- [ComVisible (true)]
- [Serializable]
- public enum FormatterTypeStyle {
-
- /// <summary>
- /// </summary>
- TypesWhenNeeded = 0,
-
- /// <summary>
- /// </summary>
- TypesAlways = 1,
-
- /// <summary>
- /// </summary>
- XsdString = 2,
- } // FormatterTypeStyle
-
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-//\r
-// System.Runtime.Serialization.Formatters.IFieldInfo\r
-//\r
-// Author:\r
-// David Dawkins (david@dawkins.st)\r
-//\r
-// (C) David Dawkins\r
-//\r
-\r
-//\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System.Runtime.InteropServices;\r
-\r
-namespace System.Runtime.Serialization.Formatters {\r
-\r
- /// <summary>\r
- /// Interface for querying field information on serialized objects.</summary>\r
- [ComVisible (true)]\r
- public interface IFieldInfo {\r
-\r
- /// <summary>\r
- /// Get or set the field names for serialized objects.</summary>\r
- string[] FieldNames {\r
- get;\r
- set;\r
- }\r
-\r
- /// <summary>\r
- /// Get or set the field types for serialized objects.</summary>\r
- Type[] FieldTypes {\r
- get;\r
- set;\r
- }\r
- }\r
-}\r
+++ /dev/null
-//\r
-// System.Runtime.Serialization.Formatters.ISoapMessage\r
-//\r
-// Author:\r
-// David Dawkins (david@dawkins.st)\r
-//\r
-// (C) David Dawkins\r
-//\r
-\r
-//\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System.Runtime.Remoting.Messaging;\r
-\r
-using System.Runtime.InteropServices;\r
-\r
-namespace System.Runtime.Serialization.Formatters {\r
-\r
- /// <summary>\r
- /// Interface for making SOAP method calls</summary>\r
- [ComVisible (true)]\r
- public interface ISoapMessage {\r
-\r
- /// <summary>\r
- /// Get or set the headers ("out-of-band" data) for the method call</summary>\r
- Header[] Headers {\r
- get;\r
- set;\r
- }\r
-\r
- /// <summary>\r
- /// Get or set the method name</summary>\r
- string MethodName {\r
- get;\r
- set;\r
- }\r
-\r
- /// <summary>\r
- /// Get or set the method parameter names</summary\r
- string[] ParamNames {\r
- get;\r
- set;\r
- }\r
-\r
- /// <summary>\r
- /// Get or set the method parameter types</summary\r
- Type[] ParamTypes {\r
- get;\r
- set;\r
- }\r
-\r
- /// <summary>\r
- /// Get or set the method parameter values</summary\r
- object[] ParamValues {\r
- get;\r
- set;\r
- }\r
-\r
- /// <summary>\r
- /// Get or set the XML namespace for the location of the called object</summary\r
- string XmlNameSpace {\r
- get;\r
- set;\r
- }\r
- }\r
-}\r
+++ /dev/null
-// InternalArrayTypeE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:43:29 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
-
- /// <summary>
- /// </summary>
- public enum InternalArrayTypeE {
-
- /// <summary>
- /// </summary>
- Empty = 0,
-
- /// <summary>
- /// </summary>
- Single = 1,
-
- /// <summary>
- /// </summary>
- Jagged = 2,
-
- /// <summary>
- /// </summary>
- Rectangular = 3,
-
- /// <summary>
- /// </summary>
- Base64 = 4,
- } // InternalArrayTypeE
-#endif
-
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalElementTypeE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:43:49 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalElementTypeE {
-
- /// <summary>
- /// </summary>
- ObjectBegin = 0,
-
- /// <summary>
- /// </summary>
- ObjectEnd = 1,
-
- /// <summary>
- /// </summary>
- Member = 2,
- } // InternalElementTypeE
-#endif
-
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalMemberTypeE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:44:09 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalMemberTypeE {
-
- /// <summary>
- /// </summary>
- Empty = 0,
-
- /// <summary>
- /// </summary>
- Header = 1,
-
- /// <summary>
- /// </summary>
- Field = 2,
-
- /// <summary>
- /// </summary>
- Item = 3,
- } // InternalMemberTypeE
-#endif
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalMemberValueE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:44:18 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalMemberValueE {
-
- /// <summary>
- /// </summary>
- Empty = 0,
-
- /// <summary>
- /// </summary>
- InlineValue = 1,
-
- /// <summary>
- /// </summary>
- Nested = 2,
-
- /// <summary>
- /// </summary>
- Reference = 3,
-
- /// <summary>
- /// </summary>
- Null = 4,
- } // InternalMemberValueE
-#endif
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalNameSpaceE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:44:28 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalNameSpaceE {
-
- /// <summary>
- /// </summary>
- None = 0,
-
- /// <summary>
- /// </summary>
- Soap = 1,
-
- /// <summary>
- /// </summary>
- XdrPrimitive = 2,
-
- /// <summary>
- /// </summary>
- XdrString = 3,
-
- /// <summary>
- /// </summary>
- UrtSystem = 4,
-
- /// <summary>
- /// </summary>
- UrtUser = 5,
-
- /// <summary>
- /// </summary>
- UserNameSpace = 6,
-
- /// <summary>
- /// </summary>
- MemberName = 7,
-
- /// <summary>
- /// </summary>
- Interop = 8,
-
- /// <summary>
- /// </summary>
- CallElement = 9,
- } // InternalNameSpaceE
-#endif
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalObjectPositionE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:44:38 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalObjectPositionE {
-
- /// <summary>
- /// </summary>
- Empty = 0,
-
- /// <summary>
- /// </summary>
- Top = 1,
-
- /// <summary>
- /// </summary>
- Child = 2,
-
- /// <summary>
- /// </summary>
- Headers = 3,
- } // InternalObjectPositionE
-#endif
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalObjectTypeE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:44:48 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalObjectTypeE {
-
- /// <summary>
- /// </summary>
- Empty = 0,
-
- /// <summary>
- /// </summary>
- Object = 1,
-
- /// <summary>
- /// </summary>
- Array = 2,
- } // InternalObjectTypeE
-#endif
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalParseStateE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:44:58 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalParseStateE {
-
- /// <summary>
- /// </summary>
- Initial = 0,
-
- /// <summary>
- /// </summary>
- Object = 1,
-
- /// <summary>
- /// </summary>
- Member = 2,
-
- /// <summary>
- /// </summary>
- MemberChild = 3,
- } // InternalParseStateE
-#endif
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalParseTypeE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:45:08 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalParseTypeE {
-
- /// <summary>
- /// </summary>
- Empty = 0,
-
- /// <summary>
- /// </summary>
- SerializedStreamHeader = 1,
-
- /// <summary>
- /// </summary>
- Object = 2,
-
- /// <summary>
- /// </summary>
- Member = 3,
-
- /// <summary>
- /// </summary>
- ObjectEnd = 4,
-
- /// <summary>
- /// </summary>
- MemberEnd = 5,
-
- /// <summary>
- /// </summary>
- Headers = 6,
-
- /// <summary>
- /// </summary>
- HeadersEnd = 7,
-
- /// <summary>
- /// </summary>
- SerializedStreamHeaderEnd = 8,
-
- /// <summary>
- /// </summary>
- Envelope = 9,
-
- /// <summary>
- /// </summary>
- EnvelopeEnd = 10,
-
- /// <summary>
- /// </summary>
- Body = 11,
-
- /// <summary>
- /// </summary>
- BodyEnd = 12,
- } // InternalParseTypeE
-#endif
-
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-// InternalPrimitiveTypeE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:43:39 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-#if ECMA
-
- /// <summary>
- /// </summary>
- public enum InternalPrimitiveTypeE {
-
- /// <summary>
- /// </summary>
- Invalid = 0,
-
- /// <summary>
- /// </summary>
- Boolean = 1,
-
- /// <summary>
- /// </summary>
- Byte = 2,
-
- /// <summary>
- /// </summary>
- Char = 3,
-
- /// <summary>
- /// </summary>
- Currency = 4,
-
- /// <summary>
- /// </summary>
- Decimal = 5,
-
- /// <summary>
- /// </summary>
- Double = 6,
-
- /// <summary>
- /// </summary>
- Int16 = 7,
-
- /// <summary>
- /// </summary>
- Int32 = 8,
-
- /// <summary>
- /// </summary>
- Int64 = 9,
-
- /// <summary>
- /// </summary>
- SByte = 10,
-
- /// <summary>
- /// </summary>
- Single = 11,
-
- /// <summary>
- /// </summary>
- TimeSpan = 12,
-
- /// <summary>
- /// </summary>
- DateTime = 13,
-
- /// <summary>
- /// </summary>
- UInt16 = 14,
-
- /// <summary>
- /// </summary>
- UInt32 = 15,
-
- /// <summary>
- /// </summary>
- UInt64 = 16,
- } // InternalPrimitiveTypeE
-#endif
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-//
-// System.Runtime.Serialization.Formatters.InternalRM.cs
-//
-// Author:
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) 2003 Andreas Nahr
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-using System.Diagnostics;
-
-namespace System.Runtime.Serialization.Formatters
-{
- //LAMESPEC: Use of this class??
- [ComVisible (true)]
- public sealed class InternalRM
- {
- public InternalRM ()
- {
- }
-
- [Conditional ("_LOGGING")]
- public static void InfoSoap (params object[] messages)
- {
- throw new NotImplementedException ();
- }
-
- public static bool SoapCheckEnabled ()
- {
- throw new NotImplementedException ();
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.Formatters.InternalST.cs
-//
-// Author:
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) 2003 Andreas Nahr
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-using System.Diagnostics;
-using System.Reflection;
-
-namespace System.Runtime.Serialization.Formatters
-{
- //LAMESPEC: Use of this class??
-
- [ComVisible (true)]
- public sealed class InternalST
- {
- private InternalST ()
- {
- }
-
- [Conditional ("_LOGGING")]
- public static void InfoSoap (params object[] messages)
- {
- throw new NotImplementedException ();
- }
-
- public static Assembly LoadAssemblyFromString (string assemblyString)
- {
- throw new NotImplementedException ();
- }
-
- public static void SerializationSetValue (FieldInfo fi,
- object target,
- object value)
- {
- throw new NotImplementedException ();
- }
-
- [Conditional ("SER_LOGGING")]
- public static void Soap (params object[] messages)
- {
- throw new NotImplementedException ();
- }
-
- [Conditional ("_DEBUG")]
- public static void SoapAssert (bool condition, string message)
- {
- throw new NotImplementedException ();
- }
-
- public static bool SoapCheckEnabled ()
- {
- throw new NotImplementedException ();
- }
- }
-}
+++ /dev/null
-// InternalSerializerTypeE.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:43:59 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization.Formatters {
-
-#if ECMA
- /// <summary>
- /// </summary>
- public enum InternalSerializerTypeE {
-
- /// <summary>
- /// </summary>
- Soap = 1,
-
- /// <summary>
- /// </summary>
- Binary = 2,
- } // InternalSerializerTypeE
-#endif
-
-} // System.Runtime.Serialization.Formatters
+++ /dev/null
-//\r
-// System.Runtime.Serialization.Formatters.ServerFault.cs\r
-//\r
-// Author: Duncan Mak (duncan@ximian.com)\r
-// Jean-Marc Andre (jean-marc.andre@polymtl.ca)\r
-//\r
-// 2002 (C) Copyright, Ximian, Inc.\r
-//\r
-\r
-//\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System;\r
-using System.Runtime.Remoting.Metadata;\r
-using System.Runtime.Serialization;\r
-\r
-using System.Runtime.InteropServices;\r
-\r
-namespace System.Runtime.Serialization.Formatters {\r
-\r
- [Serializable]\r
- [SoapType(Embedded=true)]\r
- [ComVisible (true)]\r
- public sealed class ServerFault\r
- {\r
- string exceptionType;\r
- string message;\r
- string stackTrace;\r
- \r
-#pragma warning disable 169 \r
- // Used by some remoting magic\r
- Exception exception;\r
-#pragma warning restore 169 \r
-\r
- public ServerFault (string exceptionType, string message,\r
- string stackTrace)\r
- {\r
- this.exceptionType = exceptionType;\r
- this.message = message;\r
- this.stackTrace = stackTrace;\r
- }\r
-\r
- public string ExceptionType {\r
- get { return exceptionType; }\r
- set { exceptionType = value; }\r
- }\r
-\r
- public string ExceptionMessage {\r
- get { return message; }\r
- set { message = value; }\r
- }\r
-\r
- public string StackTrace {\r
- get { return stackTrace; }\r
- set { stackTrace = value; }\r
- }\r
- }\r
-}\r
+++ /dev/null
-//\r
-// System.Runtime.Serialization.Formatters.SoapFault.cs\r
-//\r
-// Author: Duncan Mak (duncan@ximian.com)\r
-// Jean-Marc Andre (jean-marc.andre@polymtl.ca)\r
-//\r
-// 2002 (C) Copyright, Ximian, Inc.\r
-//\r
-\r
-//\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System;\r
-using System.Runtime.Remoting.Metadata;\r
-using System.Runtime.Serialization;\r
-\r
-using System.Runtime.InteropServices;\r
-\r
-namespace System.Runtime.Serialization.Formatters {\r
-\r
- [Serializable]\r
- [SoapType(Embedded=true)]\r
- [ComVisible (true)]\r
- public sealed class SoapFault : ISerializable\r
- {\r
- string code;\r
- string actor;\r
- string faultString;\r
- object detail;\r
-\r
- public SoapFault ()\r
- {\r
-\r
- }\r
-\r
- private SoapFault (SerializationInfo info, StreamingContext context)\r
- {\r
- code = info.GetString ("faultcode");\r
- faultString = info.GetString ("faultstring");\r
- detail = info.GetValue ("detail", typeof (object));\r
- }\r
-\r
- public SoapFault (string faultCode, string faultString,\r
- string faultActor, ServerFault serverFault)\r
- {\r
- this.code = faultCode;\r
- this.actor = faultActor;\r
- this.faultString = faultString;\r
- this.detail = serverFault;\r
- }\r
- \r
-\r
- public object Detail {\r
- get { return detail; }\r
- set { detail = value; }\r
- }\r
-\r
- public string FaultActor {\r
- get { return actor; }\r
- set { actor = value; }\r
- }\r
-\r
- public string FaultCode {\r
- get { return code; }\r
- set { code = value; }\r
- }\r
-\r
- public string FaultString {\r
- get { return faultString; }\r
- set { faultString = value; }\r
- }\r
- \r
- public void GetObjectData (SerializationInfo info,\r
- StreamingContext context)\r
- {\r
- info.AddValue ("faultcode", code, typeof (string));\r
- info.AddValue ("faultstring", faultString, typeof (string));\r
- info.AddValue ("detail", detail, typeof (object));\r
- }\r
- }\r
-}\r
+++ /dev/null
-//\r
-// System.Runtime.Serialization.Formatters.SoapMessage.cs\r
-//\r
-// Author: Duncan Mak (duncan@ximian.com)\r
-// Jean-Marc Andre (jean-marc.andre@polymtl.ca) \r
-//\r
-// 2002 (C) Copyright, Ximian, Inc.\r
-//\r
-\r
-//\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-using System;\r
-using System.Runtime.Remoting.Messaging;\r
-using System.Runtime.Serialization.Formatters;\r
-\r
-using System.Runtime.InteropServices;\r
-\r
-namespace System.Runtime.Serialization.Formatters {\r
-\r
- [Serializable]\r
- [ComVisible (true)]\r
- public class SoapMessage : ISoapMessage\r
- {\r
- private Header[] headers;\r
- private string methodName;\r
- private string[] paramNames;\r
- private Type[] paramTypes;\r
- private object[] paramValues;\r
- private string xmlNameSpace;\r
- \r
- public SoapMessage ()\r
- {\r
- }\r
-\r
- public Header[] Headers {\r
- get { return headers; }\r
- set { headers = value; }\r
- }\r
-\r
- public string MethodName {\r
- get { return methodName; }\r
- set { methodName = value; }\r
- }\r
-\r
- public string [] ParamNames {\r
- get { return paramNames; }\r
- set { paramNames = value; }\r
- }\r
-\r
- public Type [] ParamTypes {\r
- get { return paramTypes; }\r
- set { paramTypes = value; }\r
- }\r
-\r
- public object [] ParamValues {\r
- get { return paramValues; }\r
- set { paramValues = value; }\r
- }\r
-\r
- public string XmlNameSpace {\r
- get { return xmlNameSpace; }\r
- set { xmlNameSpace = value; }\r
- }\r
- }\r
-}\r
+++ /dev/null
-//
-// System.Runtime.Serialization.Formatters.TypeFilterLevel.cs
-//
-// Author:
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) 2003 Andreas Nahr
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization.Formatters
-{
- [ComVisible (true)]
- public enum TypeFilterLevel
- {
- Low = 2,
- Full = 3
- }
-}
+++ /dev/null
-2010-06-03 Jb Evain <jbevain@novell.com>
-
- * SafeSerializationEventArgs.cs: add new type in net_4_0.
-
-2010-06-03 Jb Evain <jbevain@novell.com>
-
- * ISafeSerializationData.cs: add new interface in net_4_0.
-
-2008-05-22 Miguel de Icaza <miguel@novell.com>
-
- * SerializationCallbacks.cs: This lock has a high contention rate
- on ASP.NET web sites, with multiple cores we end up spending a lot
- of time on this check.
-
- Rewrite this code to have two code paths since we know that the
- cache is append-only.
-
-2008-04-02 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
-
- * IFormatterConverter.cs
- * SerializationException.cs
- * StreamingContext.cs: Fix parameter names
-
-2006-12-18 Lluis Sanchez Gual <lluis@novell.com>
-
- * FormatterServices.cs: In GetFields, avoid creating a field
- clone in some cases where it's not really necessary.
-
-2006-11-13 Jensen Somers <jensen.somers@gmail.com>
-
- * Fixed the Serializable attribute in OnDeserializedAttribute,
- OnDeserializingAttribute, OnSerializedAttribute and
- OnSerializingAttribute.
-
-2006-11-13 Jensen Somers <jensen.somers@gmail.com>
-
- * Removed [Serializable] from OnDeserializedAttribute,
- OnDeserializingAttribute, OnSerializedAttribute,
- OnSerializingAttribute.
-
-2006-11-10 Jensen Somers <jensen.somers@gmail.com>
-
- * Added ComVisibleAttribute in the ISerializable,
- ISerializationSurrogate and ISurrogateSelector interface.
- * Added the sealed keyword to the OnDeserializedAttribute,
- OnDeserializingAttribute, OnSerializedAttribute,
- OnSerializingAttribute and OptionalFieldAttribute class.
-
-2006-10-30 Robert Jordan <robertj@gmx.net>
-
- * Apply ComVisibleAttribute.
-
-2006-10-29 Robert Jordan <robertj@gmx.net>
-
- * ObjectManager.cs: Add NET_2_0 serialization callbacks.
-
-2006-10-29 Robert Jordan <robertj@gmx.net>
-
- * SerializationObjectManager.cs,
- SerializationCallbacks.cs: Add support for NET_2_0 serialization
- events. See bug #78594.
-
-2006-08-06 Lluis Sanchez Gual <lluis@novell.com>
-
- * ObjectManager.cs: Add support for nested IObjectReference.
- Fixes bug #78749.
-
-2006-07-31 Sebastien Pouliot <sebastien@ximian.com>
-
- * ObjectIDGenerator.cs: Fix ArgumentNullException parameter.
-
-2006-06-04 Miguel de Icaza <miguel@novell.com>
-
- * OptionalFieldAttribute.cs, OnSerializedAttribute.cs,
- OnSerializingAttribute.cs, OnDeserializedAttribute.cs,
- OnDeserializingAttribute.cs: Added a few attributes for the
- version tolerant serialization.
-
-2006-01-04 Raja R Harinath <rharinath@novell.com>
-
- * ObjectManager.cs (ObjectRecord.IsInstanceReady): Fix regression
- introduced in previous patch. See the re-opened bug #76931.
-
-2005-12-15 Martin Baulig <martin@ximian.com>
-
- * ObjectManager.cs: When deserializing an object that has a
- surrogate, actually check the return value of
- ISerializationSurrogate.SetObjectData(); fixes #76931.
-
-2005-10-03 Lluis Sanchez Gual <lluis@novell.com>
-
- * ObjectIDGenerator.cs: Use custom comparer instead of an instance
- wrapper. Closes bug #76017.
-
-2005-06-13 Lluis Sanchez Gual <lluis@novell.com>
-
- * Formatter.cs: Properly initialize protected fields. Fixes bug #75233.
-
-2005-05-17 Lluis Sanchez Gual <lluis@novell.com>
-
- * SerializationInfo.cs: Use IsInstanceOfType instead of IsAssignableFrom
- since GetType() may not return the correct type if the object is
- a remoting proxy.
-
-2005-05-09 Lluis Sanchez Gual <lluis@novell.com>
-
- * FormatterServices.cs: In GetSerializableMembers, private fields
- from base classes must include the class name in the field name.
- In this case, it now creates a clone of the field with the
- modified name. This patch together with r44260 fixes bug #74760.
-
-2004-12-09 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectManager.cs: When deserializing an object that implements
- ISerializable, check if a surrogate exists for that object, before
- trying to deserialize it as ISerializable. This fixes bug #70104.
-
-2004-06-15 Gert Driesen <drieseng@users.sourceforge.net>
-
- * ObjectIDGenerator.cs: added TODO for serialization
-
-2004-06-09 Duncan Mak <duncan@ximian.com>
-
- * ObjectManager.cs (RegisterObject): Add checks for
- ArgumentNullException as well.
-
-2004-06-09 Duncan Mak <duncan@ximian.com>
-
- * SerializationInfoEnumerator.cs: Instead of using
- IDictionaryEnumerator from a Hashtable, use a normal IEnumerator
- from the newly added ArrayList in SerializationInfo.
-
- * SerializationInfo.cs: Added an extra ArrayList so that we can
- keep the SerializationEntrys added in the order.
- (SerializationInfo, AddValue): Throw ArgumentNullException
- correctly.
-
-
-2004-06-08 Duncan Mak <duncan@ximian.com>
-
- * ObjectManager.cs (RegisterObject): Throw
- ArgumentOutOfRangeException if the objectID parameter is less than
- or equal to zero. This check was missing from this particular
- overload.
-
-2004-05-14 Marek Safar <marek.safar@seznam.cz>
-
- * SerializationInfo.cs: Removed useless [CLSCompliant (false)]
-
-2003-11-21 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
-
- * FormatterServices.cs: Added CheckTypeSecurity() and
- GetSafeUninitializedObject().
-
-2003-11-18 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
-
- * ObjectManager.cs: Fixed header, internalized enum
- * Formatter.cs: Implemented
-
-2003-11-11 Lluis Sanchez Gual <lluis@ximian.com>
-
- * FormatterServices.cs: Fixed some comments.
-
-2003-10-21 Lluis Sanchez Gual <lluis@ximian.com>
-
- * SerializationInfo.cs: Fixed bug in GetValue. Use IsAssignableFrom instead
- of IsSubclass, since the type can be an interface.
-
-2003-10-18 Lluis Sanchez Gual <lluis@ximian.com>
-
- * FormatterServices.cs: In GetUninitializedObject methdod, reuse
- ActivationServices.AllocateUninitializedClassInstance, it does the same.
-
-2003-07-28 Duncan Mak <duncan@ximian.com>
-
- * Formatter.cs (WriteSByte): Added CLSCompliant attribute.
-
-2003-07-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
- * FormatterServices.cs:
- (GetSerializableMembers): check that all base types are serializable
- when getting their fields. Fixes bug #46875.
-
-2003-07-17 Lluis Sanchez Gual <lluis@ximian.com>
-
- * ObjectIDGenerator.cs: Optimized access to hashtable and reduced the
- number of calls to GetType(). (Patch by Paolo).
- Also added a NextId property that returns a new Id without registering
- an object.
-
-2003-06-26 Lluis Sanchez Gual <lluis@ximian.com>
-
- * SerializationInfo.cs: Fixed bug #44955
-
-2003-05-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
- * FormatterServices.cs: patch from Jean Marc that fixes bug #42742.
-
-2003-02-18 Lluis Sanchez Gual <lluis@ideary.com>
-
- * ObjectManager.cs: Corrected a problem with arrays of structs. Elements where
- not correctly updated by the final fixup.
-
-2003-01-27 Lluis Sanchez Gual <lluis@ideary.com>
-
- * ObjectManager.cs: Corrected a problem with IObjectReferece objects.
-
-2003-01-24 Martin Baulig <martin@ximian.com>
-
- * ObjectManager.cs (RaiseDeserializationEvent): Walk the object
- list in the correct order.
-
-2003-01-16 Lluis Sanchez Gual <lluis@ideary.com>
-
- * ObjectManager.cs: Implemented and added file
- * SurrogateSelector.cs: completed implementation.
- * SerializationInfo.cs: corrected a bug in GetValue method.
- * ObjectIDGenerator.cs: corrected a bug. Now it does not give the same
- id for two different instances that return true when calling Equal.
-
-2002-12-06 Duncan Mak <duncan@ximian.com>
-
- * Formatter.cs (WriteValueType): Remove the erroneous CLSCompliant attribute.
-
-2002-08-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
- * FormatterServices.cs: implemented GetUninitializedObject.
- PopulateObjectMembers needs a working FieldInfo.SetValue (it's
- not implemented right now).
-
-2002-08-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
- * FormatterServices.cs:a implemented GetSerializableMembers ().
-
-2002-08-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
- * FormatterServices.cs: New file with some implementation.
-
-2002-08-16 Dietmar Maurer <dietmar@ximian.com>
-
- * SerializationInfo.cs: special case for null values.
- use the converter everywhere.
-
-2002-08-14 Dietmar Maurer <dietmar@ximian.com>
-
- * SerializationInfo.cs: added new function to support the runtime
-
-2002-07-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
- * Formatter.cs: added namespace.
-
-2002-06-10 Duncan Mak <duncan@ximian.com>
-
- * Formatter.cs: Addd to CVS.
-
- * FormatterConverter.cs: Added to CVS.
-
- * SerializationInfo.cs (AddValue): Removed extra CLSCompliant attribute.
-
-2002-04-12 Duncan Mak <duncan@ximian.com>
-
- * SerializationException.cs: Added missing constructor for serialization.
-
-2002-03-12 Duncan Mak <duncan@ximian.com>
-
- * IFormatter.cs: Fix the return type of the Serialize method.
-
-2002/03/07 Nick Drochak <ndrochak@gol.com>
-
- * StreamingContextStates.cs: Add missing value (CrossAppDomain) and
- adjust All value accordingly.
-
-2002-03-01 Duncan Mak <duncan@ximian.com>
-
- * ObjectIDGenerator.cs: Implemented.
-
-2002-02-19 Duncan Mak <duncan@ximian.com>
-
- * SurrogateSelector.cs: Implemented.
-
- * SerializationInfoEnumerator.cs: oh, and simplified the Current
- property too.
-
- * SerializationInfo.cs: Forgot to finish up GetEnumerator ().
-
-2002-02-18 Duncan Mak <duncan@ximian.com>
-
- * SerializationInfo.cs: Converted Type.GetType calls to the faster
- typeof operator.
-
-2002-02-16 Duncan Mak <duncan@ximian.com>
-
- * SurrogateSelector.cs: Stubbed out. Gonna be working on this
- tomorrow.
-
-2002-02-15 Duncan Mak <duncan@ximian.com>
-
- * SerializationEntry.cs: Added internal constructor for writing
- bits in SerializationInfoEnumerator.
- * SerializationInfo.cs: Completed.
- * SerializationInfoEnumerator.cs: Implemented. Piggybacking on
- Hashtable's GetEnumerator method.
-
-2002-02-13 Dan Lewis <dihlewis@yahoo.co.uk>
-
- * SerializationInfoEnumerator.cs: New file (stub)
-
-2002-02-12 Duncan Mak <duncan@ximian.com>
-
- * SerializationBinder.cs: Implemented.
- * SerializationEntry.cs: Implemented.
- * SerializationInfo.cs: Fixed the get portion of the AssemblyName
- property. Implemented the FullTypename property.
-
-2002-01-06 David Dawkins <david@dawkins.st>
-
- * IFormatter.cs : New file
- * ISerializationSurrogate.cs : New file
- * ISurrogateSelector.cs : New file
-
-2002-05-01 Ravi Pratap <ravi@ximian.com>
-
- * SerializationInfo.cs : Insert MonoTODO attribute.
-
-2001-08-24 Nick Drochak <ndrochak@gol.com>
-
- * IDeserializationCallback.cs: New File
-
-Wed Nov 14 17:03:30 CET 2001 Paolo Molaro <lupus@ximian.com>
-
- * IFormatterConverter.cs, SerializationInfo.cs: CLSCompliant updates.
-
-Fri Nov 2 18:40:12 CET 2001 Paolo Molaro <lupus@ximian.com>
-
- * SerializationException.cs: implemented.
-
-2001-08-24 Nick Drochak <ndrochak@gol.com>
-
- * SerializationInfo.cs: Added all the public methods so that the compile would not break
-
-2001-07-20 Miguel de Icaza <miguel@ximian.com>
-
- * SerializationInfo.cs: New file.
-
- * IFormatterConverter.cs: New file.
-
- * ISerializable.cs: New file.
+++ /dev/null
-//
-// System.Runtime.Serialization.Formatter.cs
-//
-// Authors:
-// Duncan Mak (duncan@ximian.com)
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) Ximian, Inc.
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.IO;
-
-namespace System.Runtime.Serialization
-{
-[CLSCompliant (false)]
-[Serializable]
-[System.Runtime.InteropServices.ComVisibleAttribute (true)]
-public abstract class Formatter : IFormatter
-{
- protected Formatter ()
- {
- }
-
- protected ObjectIDGenerator m_idGenerator = new ObjectIDGenerator ();
- protected Queue m_objectQueue = new Queue ();
-
- public abstract SerializationBinder Binder {
- get;
- set;
- }
-
- public abstract StreamingContext Context {
- get;
- set;
- }
-
- public abstract ISurrogateSelector SurrogateSelector {
- get;
- set;
- }
-
- public abstract object Deserialize (Stream serializationStream);
-
- protected virtual object GetNext (out long objID)
- {
- if (m_objectQueue.Count == 0)
- {
- // set the out field to 0
- objID = 0L;
- return null;
- }
-
- Object o = m_objectQueue.Dequeue ();
- bool FirstTime;
- objID = m_idGenerator.HasId (o, out FirstTime);
-
- return o;
- }
-
- protected virtual long Schedule (object obj)
- {
- if (obj == null)
- return 0L;
-
- bool FirstTime;
- long ID = m_idGenerator.GetId (obj, out FirstTime);
- if (FirstTime)
- m_objectQueue.Enqueue (obj);
-
- return ID;
- }
-
- public abstract void Serialize (Stream serializationStream, object graph);
-
- protected abstract void WriteArray (object obj, string name, Type memberType);
-
- protected abstract void WriteBoolean (bool val, string name);
-
- protected abstract void WriteByte (byte val, string name);
-
- protected abstract void WriteChar (char val, string name);
-
- protected abstract void WriteDateTime (DateTime val, string name);
-
- protected abstract void WriteDecimal (Decimal val, string name);
-
- protected abstract void WriteDouble (double val, string name);
-
- protected abstract void WriteInt16 (short val, string name);
-
- protected abstract void WriteInt32 (int val, string name);
-
- protected abstract void WriteInt64 (long val, string name);
-
- protected virtual void WriteMember (string memberName, object data)
- {
- if (data == null)
- WriteObjectRef (data, memberName, typeof(Object));
-
- Type dataType = data.GetType ();
- if (dataType.IsArray)
- WriteArray (data, memberName, dataType);
- else if (dataType == typeof(bool))
- WriteBoolean ((bool)data, memberName);
- else if (dataType == typeof(byte))
- WriteByte ((byte)data, memberName);
- else if (dataType == typeof(char))
- WriteChar ((char)data, memberName);
- else if (dataType == typeof(DateTime))
- WriteDateTime ((DateTime)data, memberName);
- else if (dataType == typeof(decimal))
- WriteDecimal ((decimal)data, memberName);
- else if (dataType == typeof(double))
- WriteDouble ((double)data, memberName);
- else if (dataType == typeof(Int16))
- WriteInt16 ((Int16)data, memberName);
- else if (dataType == typeof(Int32))
- WriteInt32 ((Int32)data, memberName);
- else if (dataType == typeof(Int64))
- WriteInt64 ((Int64)data, memberName);
- else if (dataType == typeof(sbyte))
- WriteSByte ((sbyte)data, memberName);
- else if (dataType == typeof(float))
- WriteSingle ((float)data, memberName);
- else if (dataType == typeof(TimeSpan))
- WriteTimeSpan ((TimeSpan)data, memberName);
- else if (dataType == typeof(UInt16))
- WriteUInt16 ((UInt16)data, memberName);
- else if (dataType == typeof(UInt32))
- WriteUInt32 ((UInt32)data, memberName);
- else if (dataType == typeof(UInt64))
- WriteUInt64 ((UInt64)data, memberName);
- else if (dataType.IsValueType)
- WriteValueType (data, memberName, dataType);
-
- WriteObjectRef (data, memberName, dataType);
- }
-
- protected abstract void WriteObjectRef (object obj, string name, Type memberType);
-
-
- [CLSCompliant (false)]
- protected abstract void WriteSByte (sbyte val, string name);
-
-
- protected abstract void WriteSingle (float val, string name);
-
- protected abstract void WriteTimeSpan (TimeSpan val, string name);
-
- [CLSCompliant (false)]
- protected abstract void WriteUInt16 (ushort val, string name);
-
- [CLSCompliant (false)]
- protected abstract void WriteUInt32 (uint val, string name);
-
- [CLSCompliant (false)]
- protected abstract void WriteUInt64 (ulong val, string name);
-
- protected abstract void WriteValueType (object obj, string name, Type memberType);
-}
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.Formatter.cs
-//
-// Duncan Mak (duncan@ximian.com)
-//
-// (C) Ximian, Inc.
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.Serialization;
-
-namespace System.Runtime.Serialization {
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public class FormatterConverter : IFormatterConverter {
-
- public FormatterConverter ()
- {
- }
-
- public object Convert (object value, Type type)
- {
- return System.Convert.ChangeType (value, type);
- }
-
- public object Convert (object value, TypeCode typeCode)
- {
- return System.Convert.ChangeType (value, typeCode);
- }
-
- public bool ToBoolean (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToBoolean (value);
- }
-
- public byte ToByte (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToByte (value);
- }
-
- public char ToChar (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToChar (value);
- }
-
- public DateTime ToDateTime (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToDateTime (value);
- }
-
- public decimal ToDecimal (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToDecimal (value);
- }
-
- public double ToDouble (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToDouble (value);
- }
-
- public short ToInt16 (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToInt16 (value);
- }
-
- public int ToInt32 (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToInt32 (value);
- }
-
- public long ToInt64 (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToInt64 (value);
- }
-
- public float ToSingle (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToSingle (value);
- }
-
- public string ToString (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToString (value);
- }
-
- [CLSCompliant (false)]
- public sbyte ToSByte (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToSByte (value);
- }
-
- [CLSCompliant (false)]
- public ushort ToUInt16 (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToUInt16 (value);
- }
-
- [CLSCompliant (false)]
- public uint ToUInt32 (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToUInt32 (value);
- }
-
- [CLSCompliant (false)]
- public ulong ToUInt64 (object value)
- {
- if (value == null)
- throw new ArgumentNullException ("value is null.");
-
- return System.Convert.ToUInt64 (value);
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.FormatterServices
-//
-// Authors:
-// Gonzalo Paniagua Javier (gonzalo@ximian.com)
-//
-// (C) 2002 Ximian, Inc (http://www.ximian.com)
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Runtime.Serialization.Formatters;
-using System.Globalization;
-
-namespace System.Runtime.Serialization
-{
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- static
- public class FormatterServices
- {
- private const BindingFlags fieldFlags = BindingFlags.Public |
- BindingFlags.Instance |
- BindingFlags.NonPublic |
- BindingFlags.DeclaredOnly;
-
-
- public static object [] GetObjectData (object obj, MemberInfo [] members)
- {
- if (obj == null)
- throw new ArgumentNullException ("obj");
-
- if (members == null)
- throw new ArgumentNullException ("members");
-
- int n = members.Length;
- object [] result = new object [n];
- for (int i = 0; i < n; i++) {
- MemberInfo member = members [i];
- if (member == null)
- throw new ArgumentNullException (String.Format ("members[{0}]", i));
-
- if (member.MemberType != MemberTypes.Field)
- throw new SerializationException (
- String.Format ("members [{0}] is not a field.", i));
-
- FieldInfo fi = member as FieldInfo; // members must be fields
- result [i] = fi.GetValue (obj);
- }
-
- return result;
- }
-
- public static MemberInfo [] GetSerializableMembers (Type type)
- {
- StreamingContext st = new StreamingContext (StreamingContextStates.All);
- return GetSerializableMembers (type, st);
- }
-
- public static MemberInfo [] GetSerializableMembers (Type type, StreamingContext context)
- {
- if (type == null)
- throw new ArgumentNullException ("type");
-
- //FIXME: context?
- ArrayList fields = new ArrayList ();
- Type t = type;
- while (t != null) {
- if (!t.IsSerializable) {
- string msg = String.Format ("Type {0} in assembly {1} is not " +
- "marked as serializable.",
- t, t.Assembly.FullName);
-
- throw new SerializationException (msg);
- }
-
- GetFields (type, t, fields);
- t = t.BaseType;
- }
-
- MemberInfo [] result = new MemberInfo [fields.Count];
- fields.CopyTo (result);
- return result;
- }
-
- private static void GetFields (Type reflectedType, Type type, ArrayList fields)
- {
- FieldInfo [] fs = type.GetFields (fieldFlags);
- foreach (FieldInfo field in fs)
- if (!(field.IsNotSerialized)) {
- MonoField mf = field as MonoField;
- if (mf != null && reflectedType != type && !mf.IsPublic) {
- string fname = type.Name + "+" + mf.Name;
- fields.Add (mf.Clone (fname));
- }
- else
- fields.Add (field);
- }
- }
-
- public static Type GetTypeFromAssembly (Assembly assem, string name)
- {
- if (assem == null)
- throw new ArgumentNullException ("assem");
-
- if (name == null)
- throw new ArgumentNullException ("name");
-
- return assem.GetType (name);
- }
-
- public static object GetUninitializedObject (Type type)
- {
- if (type == null)
- throw new ArgumentNullException ("type");
-
- if (type == typeof (string))
- throw new ArgumentException ("Uninitialized Strings cannot be created.");
-
- return System.Runtime.Remoting.Activation.ActivationServices.AllocateUninitializedClassInstance (type);
- }
-
- public static object PopulateObjectMembers (object obj, MemberInfo [] members, object [] data)
- {
- if (obj == null)
- throw new ArgumentNullException ("obj");
-
- if (members == null)
- throw new ArgumentNullException ("members");
-
- if (data == null)
- throw new ArgumentNullException ("data");
-
- int length = members.Length;
- if (length != data.Length)
- throw new ArgumentException ("different length in members and data");
-
- for (int i = 0; i < length; i++) {
- MemberInfo member = members [i];
- if (member == null)
- throw new ArgumentNullException (String.Format ("members[{0}]", i));
-
- if (member.MemberType != MemberTypes.Field)
- throw new SerializationException (
- String.Format ("members [{0}] is not a field.", i));
-
- FieldInfo fi = member as FieldInfo; // members must be fields
- fi.SetValue (obj, data [i]);
- }
-
- return obj;
- }
-
-
- public static void CheckTypeSecurity (Type t, TypeFilterLevel securityLevel)
- {
- if (securityLevel == TypeFilterLevel.Full) return;
- CheckNotAssignable (typeof(System.DelegateSerializationHolder), t);
- CheckNotAssignable (typeof(System.Runtime.Remoting.Lifetime.ISponsor), t);
- CheckNotAssignable (typeof(System.Runtime.Remoting.IEnvoyInfo), t);
- CheckNotAssignable (typeof(System.Runtime.Remoting.ObjRef), t);
- }
-
- static void CheckNotAssignable (Type basetype, Type type)
- {
- if (basetype.IsAssignableFrom (type)) {
- string msg = "Type " + basetype + " and the types derived from it";
- msg += " (such as " + type + ") are not permitted to be deserialized at this security level";
- throw new System.Security.SecurityException (msg);
- }
- }
-
- public static object GetSafeUninitializedObject (Type type)
- {
- // FIXME: MS.NET uses code access permissions to check if the caller is
- // allowed to create an instance of this type. We can't support this
- // because it is not implemented in mono.
-
- // In concrete, the it will request a SecurityPermission of
- // type "Infrastructure".
-
- return GetUninitializedObject (type);
- }
-
- // This method was introduced in .Net due to a bug serializing objects with circular references
- // which we don't appear to have, so we just return the same object.
- // See http://support.microsoft.com/kb/927495/en-us/ in case of doubt.
- [ComVisible (false)]
- public static ISerializationSurrogate GetSurrogateForCyclicalReference (ISerializationSurrogate innerSurrogate)
- {
- return innerSurrogate;
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.IDeserializationCallback.cs
-//
-// Author:
-// Nick Drochak(ndrochak@gol.com)
-//
-// (C) Nick Drochak
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Runtime.Serialization {
-
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public interface IDeserializationCallback {
- void OnDeserialization(object sender);
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.IFormatter
-//
-// Author:
-// David Dawkins (david@dawkins.st)
-//
-// (C) David Dawkins
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.IO;
-
-namespace System.Runtime.Serialization {
-
- /// <summary>
- /// Formatting for serialized objects</summary>
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public interface IFormatter {
-
- //
- // Properties
- //
-
- /// <summary>
- /// Get or set the SerializationBinder used
- /// for looking up types during deserialization</summary>
- SerializationBinder Binder
- {
- get;
- set;
- }
-
- /// <summary>
- /// Get or set the StreamingContext used for serialization
- /// and deserialization</summary>
- StreamingContext Context
- {
- get;
- set;
- }
-
- /// <summary>
- /// Get or set the SurrogateSelector used by the current
- /// formatter</summary>
- ISurrogateSelector SurrogateSelector
- {
- get;
- set;
- }
-
- /// <summary>
- /// Deserialize data from the specified stream, rebuilding
- /// the object hierarchy</summary>
- object Deserialize(
- Stream serializationStream
- );
-
- /// <summary>
- /// Serialize the specified object to the specified stream.
- /// Object may be the root of a graph of objects to be
- /// serialized</summary>
- void Serialize(
- Stream serializationStream,
- object graph
- );
- }
-
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.IFormatterConverter.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.com
-//
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Runtime.Serialization {
- [CLSCompliant(false)]
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public interface IFormatterConverter {
- object Convert (object value, Type type);
- object Convert (object value, TypeCode typeCode);
-
- bool ToBoolean (object value);
- byte ToByte (object value);
- char ToChar (object value);
- DateTime ToDateTime (object value);
- Decimal ToDecimal (object value);
- double ToDouble (object value);
- Int16 ToInt16 (object value);
- Int32 ToInt32 (object value);
- Int64 ToInt64 (object value);
- sbyte ToSByte (object value);
- float ToSingle (object value);
- string ToString (object value);
- UInt16 ToUInt16 (object value);
- UInt32 ToUInt32 (object value);
- UInt64 ToUInt64 (object value);
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.IObjectReference.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Runtime.Serialization {
-
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public interface IObjectReference {
- object GetRealObject (StreamingContext context);
- }
-}
-
+++ /dev/null
-//
-// System.Runtime.Serialization.ISafeSerializationData
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization {
-
- public interface ISafeSerializationData {
- void CompleteDeserialization (object deserialized);
- }
-}
-
+++ /dev/null
-//
-// System.Runtime.Serialization.ISerializable.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.com
-//
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Runtime.Serialization {
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
-
- public interface ISerializable {
- void GetObjectData (SerializationInfo info, StreamingContext context);
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.ISerializationSurrogate
-//
-// Author:
-// David Dawkins (david@dawkins.st)
-//
-// (C) David Dawkins
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Runtime.Serialization {
-
- /// <summary>
- /// Interface for serialization surrogates</summary>
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
-
- public interface ISerializationSurrogate {
-
- /// <summary>
- /// Get the SerializationInfo necessary to serialize
- /// the specified object </summary>
- /// <param name="obj">Object to be serialized</param>
- /// <param name="info">SerializationInfo to be populated</param>
- /// <param name="context">Destination for serialization</param>
- void GetObjectData(
- object obj,
- SerializationInfo info,
- StreamingContext context
- );
-
- /// <summary>
- /// Populate an object using the specified SerializationInfo </summary>
- /// <param name="obj">Object to be populated</param>
- /// <param name="info">Data used for populating object</param>
- /// <param name="context">Source for deserialization of object</param>
- /// <param name="selector>Starting point for searching for compatible surrogates</param>
- /// <returns>The deserialized object</returns>
- object SetObjectData(
- object obj,
- SerializationInfo info,
- StreamingContext context,
- ISurrogateSelector selector
- );
- }
-
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.ISurrogateSelector
-//
-// Author:
-// David Dawkins (david@dawkins.st)
-//
-// (C) David Dawkins
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Runtime.Serialization {
-
- /// <summary>
- /// Creation of serialization surrogate selectors</summary>
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
-
- public interface ISurrogateSelector {
-
- /// <summary>
- /// Insert specified selector into available surrogates</summary>
- void ChainSelector( ISurrogateSelector selector );
-
- /// <summary>
- /// Return next surrogate in the surrogate chain</summary>
- ISurrogateSelector GetNextSelector();
-
- /// <summary>
- /// Fetch the surrogate according the specified type, starting
- /// the search from the surrogate selector for the specified
- /// StreamingContext</summary>
- /// <param name="type">Type of the object to be serialized</param>
- /// <param name="context">Context for the serialization/deserialization</para,>
- /// <param name="selector">Upon return, contains a reference to the selector where the returned surrogate was found</param>
- /// <returns>The surrogate for the specified type and context</returns>
- ISerializationSurrogate GetSurrogate(
- Type type,
- StreamingContext context,
- out ISurrogateSelector selector
- );
-
- }
-
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.ObjectIDGenerator.cs
-//
-// Author: Duncan Mak (duncan@ximian.com)
-// Lluis Sanchez (lsg@ctv.es)
-//
-// (C) Ximian, Inc.
-// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Collections;
-
-namespace System.Runtime.Serialization
-{
- [Serializable]
- [MonoTODO ("Serialization format not compatible with.NET")]
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public class ObjectIDGenerator
- {
- // Private field
- Hashtable table;
- long current; // this is the current ID, starts at 1
- static InstanceComparer comparer = new InstanceComparer ();
-
-
- // ObjectIDGenerator must generate a new id for each object instance.
- // If two objects have the same state (i.e. the method Equals() returns true),
- // each one should have a different id.
- // Thus, the object instance cannot be directly used as key of the hashtable.
- // InstanceComparer compares object references instead of object content
- // (unless the object is inmutable, like strings).
-
- class InstanceComparer: IComparer, IHashCodeProvider
- {
- int IComparer.Compare (object o1, object o2)
- {
- if (o1 is string)
- return o1.Equals(o2) ? 0 : 1;
- else
- return (o1 == o2) ? 0 : 1;
- }
-
- int IHashCodeProvider.GetHashCode (object o)
- {
- return object.InternalGetHashCode (o);
- }
- }
-
- // constructor
- public ObjectIDGenerator ()
- : base ()
- {
- table = new Hashtable (comparer, comparer);
- current = 1;
- }
-
- // Methods
- public virtual long GetId (object obj, out bool firstTime)
- {
- if (obj == null)
- throw new ArgumentNullException ("obj");
-
- object val = table [obj];
-
- if (val != null) {
- firstTime = false;
- return (long) val;
-
- } else {
- firstTime = true;
- table.Add (obj, current);
- return current ++;
- }
- }
-
- public virtual long HasId (object obj, out bool firstTime)
- {
- if (obj == null)
- throw new ArgumentNullException ("obj");
-
- object val = table [obj];
-
- if (val != null) {
- firstTime = false;
- return (long) val;
-
- } else {
- firstTime = true;
- return 0L; // 0 is the null ID
- }
- }
-
- internal long NextId
- {
- get { return current ++; }
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.ObjectManager.cs
-//
-// Author: Lluis Sanchez Gual (lluis@ideary.com)
-//
-// (C) 2003 Lluis Sanchez Gual
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.Reflection;
-
-namespace System.Runtime.Serialization
-{
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public class ObjectManager
- {
- // All objects are chained in the same order as they have been registered
- ObjectRecord _objectRecordChain = null;
- ObjectRecord _lastObjectRecord = null;
-
- ArrayList _deserializedRecords = new ArrayList();
- ArrayList _onDeserializedCallbackRecords = new ArrayList();
- Hashtable _objectRecords = new Hashtable();
- bool _finalFixup = false;
-
- ISurrogateSelector _selector;
- StreamingContext _context;
- int _registeredObjectsCount = 0;
-
- public ObjectManager(ISurrogateSelector selector, StreamingContext context)
- {
- _selector = selector;
- _context = context;
- }
-
- public virtual void DoFixups()
- {
- _finalFixup = true;
-
- try
- {
- if (_registeredObjectsCount < _objectRecords.Count)
- throw new SerializationException ("There are some fixups that refer to objects that have not been registered");
-
-
- ObjectRecord last = _lastObjectRecord;
-
- bool firstCycle = true;
- bool lastCycle = false;
- int unresolvedCount = 0; // Unresolved objects found in the current cycle
- int lastUnresolvedCount = 0; // Unresolved objects before the current cycle
-
- // Solve al pending fixups of all objects
-
- ObjectRecord record = _objectRecordChain;
- while (record != null)
- {
- // We ignore object references in the first cycle
- bool ready = !(record.IsUnsolvedObjectReference && firstCycle);
- if (ready) ready = record.DoFixups (true, this, true);
- if (ready) ready = record.LoadData(this, _selector, _context);
-
- ObjectRecord next;
-
- if (ready)
- {
- if (record.OriginalObject is IDeserializationCallback)
- _deserializedRecords.Add (record);
-
- SerializationCallbacks sc = SerializationCallbacks
- .GetSerializationCallbacks (record.OriginalObject.GetType ());
- if (sc.HasDeserializedCallbacks)
- _onDeserializedCallbackRecords.Add (record);
- next = record.Next;
- }
- else
- {
- // There must be an unresolved IObjectReference instance.
- // Chain the record at the end so it is solved later
-
- if ((record.ObjectInstance is IObjectReference) && !firstCycle)
- {
- if (record.IsUnsolvedObjectReference && lastCycle)
- // No more chances to resolve
- throw new SerializationException ("The object with ID " + record.ObjectID + " could not be resolved");
- else {
- unresolvedCount++;
- }
- }
-
- if (record != _lastObjectRecord) {
- next = record.Next;
- record.Next = null;
- _lastObjectRecord.Next = record;
- _lastObjectRecord = record;
- }
- else
- next = record;
- }
-
- if (record == last) {
- last = _lastObjectRecord;
- if (firstCycle)
- firstCycle = false;
- else {
- if (lastUnresolvedCount == unresolvedCount)
- lastCycle = true;
- }
- lastUnresolvedCount = unresolvedCount;
- unresolvedCount = 0;
- }
- record = next;
- }
- }
- finally
- {
- _finalFixup = false;
- }
- }
-
- internal ObjectRecord GetObjectRecord (long objectID)
- {
- ObjectRecord rec = (ObjectRecord)_objectRecords[objectID];
- if (rec == null)
- {
- if (_finalFixup) throw new SerializationException ("The object with Id " + objectID + " has not been registered");
- rec = new ObjectRecord();
- rec.ObjectID = objectID;
- _objectRecords[objectID] = rec;
- }
- if (!rec.IsRegistered && _finalFixup) throw new SerializationException ("The object with Id " + objectID + " has not been registered");
- return rec;
- }
-
- public virtual object GetObject (long objectID)
- {
- if (objectID <= 0) throw new ArgumentOutOfRangeException("objectID","The objectID parameter is less than or equal to zero");
- ObjectRecord rec = (ObjectRecord)_objectRecords[objectID];
- if (rec == null || !rec.IsRegistered) return null;
- else return rec.ObjectInstance;
- }
-
- public virtual void RaiseDeserializationEvent ()
- {
- for (int i = _onDeserializedCallbackRecords.Count-1; i >= 0; i--)
- {
- ObjectRecord record = (ObjectRecord) _onDeserializedCallbackRecords [i];
- RaiseOnDeserializedEvent (record.OriginalObject);
- }
- for (int i = _deserializedRecords.Count-1; i >= 0; i--)
- {
- ObjectRecord record = (ObjectRecord) _deserializedRecords [i];
- IDeserializationCallback obj = record.OriginalObject as IDeserializationCallback;
- if (obj != null) obj.OnDeserialization (this);
- }
-
- }
-
- public void RaiseOnDeserializingEvent (object obj)
- {
- SerializationCallbacks sc = SerializationCallbacks
- .GetSerializationCallbacks (obj.GetType ());
- sc.RaiseOnDeserializing (obj, _context);
- }
-
- void RaiseOnDeserializedEvent (object obj)
- {
- SerializationCallbacks sc = SerializationCallbacks
- .GetSerializationCallbacks (obj.GetType ());
- sc.RaiseOnDeserialized (obj, _context);
- }
-
- private void AddFixup (BaseFixupRecord record)
- {
- record.ObjectToBeFixed.ChainFixup (record, true);
- record.ObjectRequired.ChainFixup (record, false);
- }
-
- public virtual void RecordArrayElementFixup (long arrayToBeFixed, int index, long objectRequired)
- {
- if (arrayToBeFixed <= 0) throw new ArgumentOutOfRangeException("arrayToBeFixed","The arrayToBeFixed parameter is less than or equal to zero");
- if (objectRequired <= 0) throw new ArgumentOutOfRangeException("objectRequired","The objectRequired parameter is less than or equal to zero");
- ArrayFixupRecord record = new ArrayFixupRecord(GetObjectRecord(arrayToBeFixed), index, GetObjectRecord(objectRequired));
- AddFixup (record);
- }
-
- public virtual void RecordArrayElementFixup (long arrayToBeFixed, int[] indices, long objectRequired)
- {
- if (arrayToBeFixed <= 0) throw new ArgumentOutOfRangeException("arrayToBeFixed","The arrayToBeFixed parameter is less than or equal to zero");
- if (objectRequired <= 0) throw new ArgumentOutOfRangeException("objectRequired","The objectRequired parameter is less than or equal to zero");
- if (indices == null) throw new ArgumentNullException("indices");
- MultiArrayFixupRecord record = new MultiArrayFixupRecord (GetObjectRecord(arrayToBeFixed), indices, GetObjectRecord(objectRequired));
- AddFixup (record);
- }
-
- public virtual void RecordDelayedFixup (long objectToBeFixed, string memberName, long objectRequired)
- {
- if (objectToBeFixed <= 0) throw new ArgumentOutOfRangeException("objectToBeFixed","The objectToBeFixed parameter is less than or equal to zero");
- if (objectRequired <= 0) throw new ArgumentOutOfRangeException("objectRequired","The objectRequired parameter is less than or equal to zero");
- if (memberName == null) throw new ArgumentNullException("memberName");
- DelayedFixupRecord record = new DelayedFixupRecord (GetObjectRecord(objectToBeFixed), memberName, GetObjectRecord(objectRequired));
- AddFixup (record);
- }
-
- public virtual void RecordFixup (long objectToBeFixed, MemberInfo member, long objectRequired)
- {
- if (objectToBeFixed <= 0) throw new ArgumentOutOfRangeException("objectToBeFixed","The objectToBeFixed parameter is less than or equal to zero");
- if (objectRequired <= 0) throw new ArgumentOutOfRangeException("objectRequired","The objectRequired parameter is less than or equal to zero");
- if (member == null) throw new ArgumentNullException("member");
- FixupRecord record = new FixupRecord (GetObjectRecord(objectToBeFixed), member, GetObjectRecord(objectRequired));
- AddFixup (record);
- }
-
- private void RegisterObjectInternal (object obj, ObjectRecord record)
- {
- if (obj == null) throw new ArgumentNullException("obj");
-
- if (record.IsRegistered)
- {
- if (record.OriginalObject != obj) throw new SerializationException ("An object with Id " + record.ObjectID + " has already been registered");
- else return;
- }
-
- record.ObjectInstance = obj;
- record.OriginalObject = obj;
-
- if (obj is IObjectReference) record.Status = ObjectRecordStatus.ReferenceUnsolved;
- else record.Status = ObjectRecordStatus.ReferenceSolved;
-
- if (_selector != null) {
- record.Surrogate = _selector.GetSurrogate (
- obj.GetType(), _context, out record.SurrogateSelector);
- if (record.Surrogate != null)
- record.Status = ObjectRecordStatus.ReferenceUnsolved;
- }
-
- record.DoFixups (true, this, false);
- record.DoFixups (false, this, false);
- _registeredObjectsCount++;
-
- // Adds the object to the chain of registered objects. This chain
- // is needed to be able to to perform the final fixups in the right order
-
- if (_objectRecordChain == null)
- {
- _objectRecordChain = record;
- _lastObjectRecord = record;
- }
- else
- {
- _lastObjectRecord.Next = record;
- _lastObjectRecord = record;
- }
- }
-
-
- public virtual void RegisterObject (object obj, long objectID)
- {
- if (obj == null) throw new ArgumentNullException("obj", "The obj parameter is null.");
- if (objectID <= 0) throw new ArgumentOutOfRangeException("objectID","The objectID parameter is less than or equal to zero");
- RegisterObjectInternal (obj, GetObjectRecord (objectID));
- }
-
- public void RegisterObject (object obj, long objectID, SerializationInfo info)
- {
- if (obj == null) throw new ArgumentNullException("obj", "The obj parameter is null.");
- if (objectID <= 0) throw new ArgumentOutOfRangeException("objectID","The objectID parameter is less than or equal to zero");
-
- ObjectRecord record = GetObjectRecord (objectID);
- record.Info = info;
- RegisterObjectInternal (obj, record);
- }
-
- public void RegisterObject (object obj, long objectID, SerializationInfo info, long idOfContainingObj, MemberInfo member)
- {
- RegisterObject (obj, objectID, info, idOfContainingObj, member, null);
- }
-
- public void RegisterObject( object obj, long objectID, SerializationInfo info, long idOfContainingObj, MemberInfo member, int[] arrayIndex)
- {
- if (obj == null) throw new ArgumentNullException("obj", "The obj parameter is null.");
- if (objectID <= 0) throw new ArgumentOutOfRangeException("objectID","The objectID parameter is less than or equal to zero");
-
- ObjectRecord record = GetObjectRecord (objectID);
- record.Info = info;
- record.IdOfContainingObj = idOfContainingObj;
- record.Member = member;
- record.ArrayIndex = arrayIndex;
- RegisterObjectInternal (obj, record);
- }
- }
-
-
-
- // Fixup types. There is a fixup class for each fixup type.
-
- // BaseFixupRecord
- // Base class for all fixups
-
- internal abstract class BaseFixupRecord
- {
- public BaseFixupRecord(ObjectRecord objectToBeFixed, ObjectRecord objectRequired)
- {
- ObjectToBeFixed = objectToBeFixed;
- ObjectRequired = objectRequired;
- }
-
- public bool DoFixup (ObjectManager manager, bool strict)
- {
- if (ObjectToBeFixed.IsRegistered && ObjectRequired.IsInstanceReady)
- {
- FixupImpl (manager);
- return true;
- }
- else if (strict)
- {
- if (!ObjectToBeFixed.IsRegistered) throw new SerializationException ("An object with ID " + ObjectToBeFixed.ObjectID + " was included in a fixup, but it has not been registered");
- else if (!ObjectRequired.IsRegistered) throw new SerializationException ("An object with ID " + ObjectRequired.ObjectID + " was included in a fixup, but it has not been registered");
- else return false;
- }
- else
- return false;
- }
-
- protected abstract void FixupImpl (ObjectManager manager);
-
- internal protected ObjectRecord ObjectToBeFixed;
- internal protected ObjectRecord ObjectRequired;
-
- public BaseFixupRecord NextSameContainer;
- public BaseFixupRecord NextSameRequired;
- }
-
- // ArrayFixupRecord
- // Fixup for assigning a value to one position of an array
-
- internal class ArrayFixupRecord : BaseFixupRecord
- {
- int _index;
-
- public ArrayFixupRecord (ObjectRecord objectToBeFixed, int index, ObjectRecord objectRequired): base (objectToBeFixed, objectRequired) {
- _index = index;
- }
-
- protected override void FixupImpl (ObjectManager manager) {
- Array array = (Array)ObjectToBeFixed.ObjectInstance;
- array.SetValue (ObjectRequired.ObjectInstance, _index);
- }
- }
-
- // MultiArrayFixupRecord
- // Fixup for assigning a value to several positions of an array
-
- internal class MultiArrayFixupRecord : BaseFixupRecord
- {
- int[] _indices;
-
- public MultiArrayFixupRecord (ObjectRecord objectToBeFixed, int[] indices, ObjectRecord objectRequired): base (objectToBeFixed, objectRequired) {
- _indices = indices;
- }
-
- protected override void FixupImpl (ObjectManager manager) {
- ObjectToBeFixed.SetArrayValue (manager, ObjectRequired.ObjectInstance, _indices);
- }
- }
-
- // FixupRecord
- // Fixup for assigning a value to a member of an object
-
- internal class FixupRecord: BaseFixupRecord
- {
- public MemberInfo _member;
-
- public FixupRecord (ObjectRecord objectToBeFixed, MemberInfo member, ObjectRecord objectRequired): base (objectToBeFixed, objectRequired) {
- _member = member;
- }
-
- protected override void FixupImpl (ObjectManager manager) {
- ObjectToBeFixed.SetMemberValue (manager, _member, ObjectRequired.ObjectInstance);
- }
- }
-
- // DelayedFixupRecord
- // Fixup for assigning a value to a SerializationInfo of an object
-
- internal class DelayedFixupRecord: BaseFixupRecord
- {
- public string _memberName;
-
- public DelayedFixupRecord (ObjectRecord objectToBeFixed, string memberName, ObjectRecord objectRequired): base (objectToBeFixed, objectRequired) {
- _memberName = memberName;
- }
-
- protected override void FixupImpl (ObjectManager manager) {
- ObjectToBeFixed.SetMemberValue (manager, _memberName, ObjectRequired.ObjectInstance);
- }
- }
-
- // Object Record
-
- internal enum ObjectRecordStatus: byte { Unregistered, ReferenceUnsolved, ReferenceSolved }
-
- internal class ObjectRecord
- {
- public ObjectRecordStatus Status = ObjectRecordStatus.Unregistered;
- public object OriginalObject;
- public object ObjectInstance;
- public long ObjectID;
- public SerializationInfo Info;
- public long IdOfContainingObj;
- public ISerializationSurrogate Surrogate;
- public ISurrogateSelector SurrogateSelector;
- public MemberInfo Member;
- public int[] ArrayIndex;
- public BaseFixupRecord FixupChainAsContainer;
- public BaseFixupRecord FixupChainAsRequired;
- public ObjectRecord Next;
-
- public void SetMemberValue (ObjectManager manager, MemberInfo member, object value)
- {
- if (member is FieldInfo)
- ((FieldInfo)member).SetValue (ObjectInstance, value);
- else if (member is PropertyInfo)
- ((PropertyInfo)member).SetValue (ObjectInstance, value, null);
- else throw new SerializationException ("Cannot perform fixup");
-
- if (Member != null)
- {
- ObjectRecord containerRecord = manager.GetObjectRecord (IdOfContainingObj);
- if (containerRecord.IsRegistered)
- containerRecord.SetMemberValue (manager, Member, ObjectInstance);
- }
- else if (ArrayIndex != null)
- {
- ObjectRecord containerRecord = manager.GetObjectRecord (IdOfContainingObj);
- if (containerRecord.IsRegistered)
- containerRecord.SetArrayValue (manager, ObjectInstance, ArrayIndex);
- }
- }
- public void SetArrayValue (ObjectManager manager, object value, int[] indices)
- {
- ((Array)ObjectInstance).SetValue (value, indices);
- }
-
- public void SetMemberValue (ObjectManager manager, string memberName, object value)
- {
- if (Info == null) throw new SerializationException ("Cannot perform fixup");
- Info.AddValue (memberName, value, value.GetType());
- }
-
- public bool IsInstanceReady
- {
- // Returns true if this object is ready to be assigned to a parent object.
- get
- {
- if (!IsRegistered) return false;
- if (IsUnsolvedObjectReference) return false;
-
- // Embedded value objects cannot be assigned to their containers until fully completed
- if (ObjectInstance.GetType ().IsValueType && (HasPendingFixups || Info != null))
- return false;
-
- return true;
- }
- }
-
- public bool IsUnsolvedObjectReference
- {
- get {
- return Status != ObjectRecordStatus.ReferenceSolved;
- }
- }
-
- public bool IsRegistered
- {
- get {
- return Status != ObjectRecordStatus.Unregistered;
- }
- }
-
- public bool DoFixups (bool asContainer, ObjectManager manager, bool strict)
- {
- BaseFixupRecord prevFixup = null;
- BaseFixupRecord fixup = asContainer ? FixupChainAsContainer : FixupChainAsRequired;
- bool allFixed = true;
-
- while (fixup != null)
- {
- if (fixup.DoFixup (manager, strict))
- {
- UnchainFixup (fixup, prevFixup, asContainer);
- if (asContainer) fixup.ObjectRequired.RemoveFixup (fixup, false);
- else fixup.ObjectToBeFixed.RemoveFixup (fixup, true);
- }
- else
- {
- prevFixup = fixup;
- allFixed = false;
- }
-
- fixup = asContainer ? fixup.NextSameContainer : fixup.NextSameRequired;
- }
- return allFixed;
- }
-
- public void RemoveFixup (BaseFixupRecord fixupToRemove, bool asContainer)
- {
- BaseFixupRecord prevFixup = null;
- BaseFixupRecord fixup = asContainer ? FixupChainAsContainer : FixupChainAsRequired;
- while (fixup != null)
- {
- if (fixup == fixupToRemove)
- {
- UnchainFixup (fixup, prevFixup, asContainer);
- return;
- }
- prevFixup = fixup;
- fixup = asContainer ? fixup.NextSameContainer : fixup.NextSameRequired;
- }
- }
-
- private void UnchainFixup (BaseFixupRecord fixup, BaseFixupRecord prevFixup, bool asContainer)
- {
- if (prevFixup == null) {
- if (asContainer) FixupChainAsContainer = fixup.NextSameContainer;
- else FixupChainAsRequired = fixup.NextSameRequired;
- }
- else {
- if (asContainer) prevFixup.NextSameContainer = fixup.NextSameContainer;
- else prevFixup.NextSameRequired = fixup.NextSameRequired;
- }
- }
-
- public void ChainFixup (BaseFixupRecord fixup, bool asContainer)
- {
- if (asContainer)
- {
- fixup.NextSameContainer = FixupChainAsContainer;
- FixupChainAsContainer = fixup;
- }
- else
- {
- fixup.NextSameRequired = FixupChainAsRequired;
- FixupChainAsRequired = fixup;
- }
- }
-
- public bool LoadData (ObjectManager manager, ISurrogateSelector selector, StreamingContext context)
- {
- if (Info != null)
- {
- if (Surrogate != null) {
- object new_obj = Surrogate.SetObjectData (ObjectInstance, Info, context, SurrogateSelector);
- if (new_obj != null)
- ObjectInstance = new_obj;
- Status = ObjectRecordStatus.ReferenceSolved;
- } else if (ObjectInstance is ISerializable) {
- object[] pars = new object[] {Info, context};
- ConstructorInfo con = ObjectInstance.GetType().GetConstructor (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof (SerializationInfo), typeof (StreamingContext) }, null );
- if (con == null) throw new SerializationException ("The constructor to deserialize an object of type " + ObjectInstance.GetType().FullName + " was not found.");
- con.Invoke (ObjectInstance, pars);
- } else {
- throw new SerializationException ("No surrogate selector was found for type " + ObjectInstance.GetType().FullName);
- }
-
- Info = null;
- }
-
- if (ObjectInstance is IObjectReference && Status != ObjectRecordStatus.ReferenceSolved)
- {
- try {
- ObjectInstance = ((IObjectReference)ObjectInstance).GetRealObject(context);
- int n = 100;
- while (ObjectInstance is IObjectReference && n > 0) {
- object ob = ((IObjectReference)ObjectInstance).GetRealObject (context);
- if (ob == ObjectInstance)
- break;
- ObjectInstance = ob;
- n--;
- }
- if (n == 0)
- throw new SerializationException ("The implementation of the IObjectReference interface returns too many nested references to other objects that implement IObjectReference.");
-
- Status = ObjectRecordStatus.ReferenceSolved;
- }
- catch (NullReferenceException) {
- // Give a second chance
- return false;
- }
- }
-
- if (Member != null)
- {
- // If this object is a value object embedded in another object, the parent
- // object must be updated
-
- ObjectRecord containerRecord = manager.GetObjectRecord (IdOfContainingObj);
- containerRecord.SetMemberValue (manager, Member, ObjectInstance);
- }
- else if (ArrayIndex != null)
- {
- ObjectRecord containerRecord = manager.GetObjectRecord (IdOfContainingObj);
- containerRecord.SetArrayValue (manager, ObjectInstance, ArrayIndex);
- }
-
- return true;
- }
-
- public bool HasPendingFixups
- {
- get { return FixupChainAsContainer != null; }
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.OnDeserializedAttribute.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization {
-
- [ComVisible(true)]
- [AttributeUsage (AttributeTargets.Method, Inherited=false)]
- public sealed class OnDeserializedAttribute : Attribute {
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.OnDeserializingAttribute.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization {
-
- [ComVisible(true)]
- [AttributeUsage (AttributeTargets.Method, Inherited=false)]
- public sealed class OnDeserializingAttribute : Attribute {
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.OnSerializedAttribute.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization {
-
- [ComVisible(true)]
- [AttributeUsage (AttributeTargets.Method, Inherited=false)]
- public sealed class OnSerializedAttribute : Attribute {
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.OnSerializingAttribute.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization {
-
- [ComVisible(true)]
- [AttributeUsage (AttributeTargets.Method, Inherited=false)]
- public sealed class OnSerializingAttribute : Attribute {
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.OptionalFieldAttribute.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization {
-
- [ComVisible(true)]
- [AttributeUsage (AttributeTargets.Field, Inherited=false)]
- public sealed class OptionalFieldAttribute : Attribute {
- int version_added;
-
- public int VersionAdded {
- get {
- return version_added;
- }
-
- set {
- version_added = value;
- }
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.SafeSerializationEventArgs
-//
-// Author:
-// Jb Evain (jbevain@novell.com)
-//
-// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization {
-
- public sealed class SafeSerializationEventArgs : EventArgs {
-
- [MonoTODO]
- public StreamingContext StreamingContext {
- get { throw new NotImplementedException (); }
- }
-
- internal SafeSerializationEventArgs ()
- {
- }
-
- [MonoTODO]
- public void AddSerializedState (ISafeSerializationData serializedState)
- {
- throw new NotImplementedException ();
- }
- }
-}
-
+++ /dev/null
-//
-// System.Runtime.Serialization.SerializationBinder.cs
-//
-// Author: Duncan Mak (duncan@ximian.com)
-//
-// (C) Ximian, Inc.
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Runtime.Serialization
-{
- [Serializable]
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public abstract class SerializationBinder
- {
- // Constructor
- protected SerializationBinder ()
- : base ()
- {
- }
-
- public abstract Type BindToType (string assemblyName, string typeName);
-
- public virtual void BindToName (Type serializedType, out string assemblyName, out string typeName)
- {
- assemblyName = null;
- typeName = null;
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.SerializationCallbacks.cs
-//
-// Author:
-// Robert Jordan (robertj@gmx.net)
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.Reflection;
-
-namespace System.Runtime.Serialization {
-
- internal sealed class SerializationCallbacks
- {
- public delegate void CallbackHandler (StreamingContext context);
-
- readonly ArrayList onSerializingList;
- readonly ArrayList onSerializedList;
- readonly ArrayList onDeserializingList;
- readonly ArrayList onDeserializedList;
-
- public bool HasSerializingCallbacks {
- get {return onSerializingList != null;}
- }
-
- public bool HasSerializedCallbacks {
- get {return onSerializedList != null;}
- }
-
- public bool HasDeserializingCallbacks {
- get {return onDeserializingList != null;}
- }
-
- public bool HasDeserializedCallbacks {
- get {return onDeserializedList != null;}
- }
-
- public SerializationCallbacks (Type type)
- {
- onSerializingList = GetMethodsByAttribute (type, typeof (OnSerializingAttribute));
- onSerializedList = GetMethodsByAttribute (type, typeof (OnSerializedAttribute));
- onDeserializingList = GetMethodsByAttribute (type, typeof (OnDeserializingAttribute));
- onDeserializedList = GetMethodsByAttribute (type, typeof (OnDeserializedAttribute));
- }
-
- const BindingFlags DefaultBindingFlags = BindingFlags.Public | BindingFlags.NonPublic |
- BindingFlags.Instance | BindingFlags.DeclaredOnly;
-
-
- static ArrayList GetMethodsByAttribute (Type type, Type attr)
- {
- ArrayList list = new ArrayList ();
-
- Type t = type;
- while (t != typeof (object)) {
- int count = 0;
-
- foreach (MethodInfo mi in t.GetMethods (DefaultBindingFlags)) {
- if (mi.IsDefined (attr, false)) {
- list.Add (mi);
- count++;
- }
- }
-
- // FIXME: MS.NET is checking for this with the verifier at assembly load time.
- if (count > 1)
- throw new TypeLoadException (
- String.Format ("Type '{0}' has more than one method with the following attribute: '{1}'.", type.AssemblyQualifiedName, attr.FullName));
-
- t = t.BaseType;
- }
-
- // optimize memory usage
- return list.Count == 0 ? null : list;
- }
-
- static void Invoke (ArrayList list, object target, StreamingContext context)
- {
- if (list == null)
- return;
-
- CallbackHandler handler = null;
-
- // construct a delegate from the specified list
- foreach (MethodInfo mi in list) {
- handler = (CallbackHandler)
- Delegate.Combine (
- Delegate.CreateDelegate (typeof (CallbackHandler), target, mi),
- handler);
- }
-
- handler (context);
- }
-
- public void RaiseOnSerializing (object target, StreamingContext contex)
- {
- Invoke (onSerializingList, target, contex);
- }
-
- public void RaiseOnSerialized (object target, StreamingContext contex)
- {
- Invoke (onSerializedList, target, contex);
- }
-
- public void RaiseOnDeserializing (object target, StreamingContext contex)
- {
- Invoke (onDeserializingList, target, contex);
- }
-
- public void RaiseOnDeserialized (object target, StreamingContext contex)
- {
- Invoke (onDeserializedList, target, contex);
- }
-
- static Hashtable cache = new Hashtable ();
- static object cache_lock = new object ();
-
- public static SerializationCallbacks GetSerializationCallbacks (Type t)
- {
- SerializationCallbacks sc = (SerializationCallbacks) cache [t];
- if (sc != null)
- return sc;
-
- // Slow path, new entry, we need to copy
- lock (cache_lock){
- sc = (SerializationCallbacks) cache [t];
- if (sc == null) {
- Hashtable copy = (Hashtable) cache.Clone ();
-
- sc = new SerializationCallbacks (t);
- copy [t] = sc;
- cache = copy;
- }
- return sc;
- }
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.SerializationEntry.cs
-//
-// Author: Duncan Mak (duncan@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-namespace System.Runtime.Serialization
-{
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public struct SerializationEntry
- {
- string name;
- Type objectType;
- object value;
-
- // Properties
- public string Name
- {
- get { return name; }
- }
-
- public Type ObjectType
- {
- get { return objectType; }
- }
-
- public object Value
- {
- get { return value; }
- }
-
- internal SerializationEntry (string name, Type type, object value)
- {
- this.name = name;
- this.objectType = type;
- this.value = value;
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization/SerializationException.cs
-//
-// Author:
-// Paolo Molaro (lupus@ximian.com)
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.Serialization;
-
-namespace System.Runtime.Serialization {
-
- [Serializable]
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public class SerializationException : SystemException {
- // Constructors
- public SerializationException ()
- : base ("An error occurred during (de)serialization")
- {
- }
-
- public SerializationException (string message)
- : base (message)
- {
- }
-
- public SerializationException (string message, Exception innerException)
- : base (message, innerException)
- {
- }
-
- protected SerializationException (SerializationInfo info, StreamingContext context)
- : base (info, context)
- {
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.SerializationInfo.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-// Duncan Mak (duncan@ximian.com)
-// Dietmar Maurer (dietmar@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.com
-//
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-
-namespace System.Runtime.Serialization
-{
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public sealed class SerializationInfo
- {
- Dictionary<string, SerializationEntry> serialized = new Dictionary<string, SerializationEntry> ();
- List<SerializationEntry> values = new List<SerializationEntry> ();
-
- string assemblyName; // the assembly being serialized
- string fullTypeName; // the type being serialized.
- Type objectType;
- bool isAssemblyNameSetExplicit;
- bool isFullTypeNameSetExplicit;
-
- IFormatterConverter converter;
-
- /* used by the runtime */
- private SerializationInfo (Type type)
- {
- assemblyName = type.Assembly.FullName;
- fullTypeName = type.FullName;
- converter = new FormatterConverter ();
- objectType = type;
- }
-
- /* used by the runtime */
- private SerializationInfo (Type type, SerializationEntry [] data)
- {
- int len = data.Length;
-
- assemblyName = type.Assembly.FullName;
- fullTypeName = type.FullName;
- converter = new FormatterConverter ();
- objectType = type;
-
- for (int i = 0; i < len; i++) {
- serialized.Add (data [i].Name, data [i]);
- values.Add (data [i]);
- }
- }
-
- // Constructor
- [CLSCompliant (false)]
- public SerializationInfo (Type type, IFormatterConverter converter)
- {
- if (type == null)
- throw new ArgumentNullException ("type", "Null argument");
-
- if (converter == null)
- throw new ArgumentNullException ("converter", "Null argument");
-
- this.converter = converter;
- assemblyName = type.Assembly.FullName;
- fullTypeName = type.FullName;
- objectType = type;
- }
-
- // Properties
- public string AssemblyName
- {
- get { return assemblyName; }
-
- set {
- if (value == null)
- throw new ArgumentNullException ("Argument is null.");
- assemblyName = value;
- isAssemblyNameSetExplicit = true;
- }
- }
-
- public string FullTypeName
- {
- get { return fullTypeName; }
-
- set {
- if ( value == null)
- throw new ArgumentNullException ("Argument is null.");
- fullTypeName = value;
- isFullTypeNameSetExplicit = true;
- }
- }
-
- public int MemberCount
- {
- get { return serialized.Count; }
- }
-
- public bool IsAssemblyNameSetExplicit {
- get {
- return isAssemblyNameSetExplicit;
- }
- }
-
- public bool IsFullTypeNameSetExplicit {
- get {
- return isFullTypeNameSetExplicit;
- }
- }
-
- public Type ObjectType {
- get {
- return objectType;
- }
- }
-
- // Methods
- public void AddValue (string name, object value, Type type)
- {
- if (name == null)
- throw new ArgumentNullException ("name is null");
- if (type == null)
- throw new ArgumentNullException ("type is null");
-
- if (serialized.ContainsKey (name))
- throw new SerializationException ("Value has been serialized already.");
-
- SerializationEntry entry = new SerializationEntry (name, type, value);
-
- serialized.Add (name, entry);
- values.Add (entry);
- }
-
- public object GetValue (string name, Type type)
- {
- if (name == null)
- throw new ArgumentNullException ("name is null.");
- if (type == null)
- throw new ArgumentNullException ("type");
- if (!serialized.ContainsKey (name))
- throw new SerializationException ("No element named " + name + " could be found.");
-
- SerializationEntry entry = serialized [name];
-
- if (entry.Value != null && !type.IsInstanceOfType (entry.Value))
- return converter.Convert (entry.Value, type);
- else
- return entry.Value;
- }
-
- internal bool HasKey (string name)
- {
- return serialized.ContainsKey (name);
- }
-
- public void SetType (Type type)
- {
- if (type == null)
- throw new ArgumentNullException ("type is null.");
-
- fullTypeName = type.FullName;
- assemblyName = type.Assembly.FullName;
- objectType = type;
- isAssemblyNameSetExplicit = false;
- isFullTypeNameSetExplicit = false;
- }
-
- public SerializationInfoEnumerator GetEnumerator ()
- {
- return new SerializationInfoEnumerator (values);
- }
-
- public void AddValue (string name, short value)
- {
- AddValue (name, value, typeof (System.Int16));
- }
-
- [CLSCompliant(false)]
- public void AddValue (string name, UInt16 value)
- {
- AddValue (name, value, typeof (System.UInt16));
- }
-
- public void AddValue (string name, int value)
- {
- AddValue (name, value, typeof (System.Int32));
- }
-
- public void AddValue (string name, byte value)
- {
- AddValue (name, value, typeof (System.Byte));
- }
-
- public void AddValue (string name, bool value)
- {
- AddValue (name, value, typeof (System.Boolean));
- }
-
- public void AddValue (string name, char value)
- {
- AddValue (name, value, typeof (System.Char));
- }
-
- [CLSCompliant(false)]
- public void AddValue (string name, SByte value)
- {
- AddValue (name, value, typeof (System.SByte));
- }
-
- public void AddValue (string name, double value)
- {
- AddValue (name, value, typeof (System.Double));
- }
-
- public void AddValue (string name, Decimal value)
- {
- AddValue (name, value, typeof (System.Decimal));
- }
-
- public void AddValue (string name, DateTime value)
- {
- AddValue (name, value, typeof (System.DateTime));
- }
-
- public void AddValue (string name, float value)
- {
- AddValue (name, value, typeof (System.Single));
- }
-
- [CLSCompliant(false)]
- public void AddValue (string name, UInt32 value)
- {
- AddValue (name, value, typeof (System.UInt32));
- }
-
- public void AddValue (string name, long value)
- {
- AddValue (name, value, typeof (System.Int64));
- }
-
- [CLSCompliant(false)]
- public void AddValue (string name, UInt64 value)
- {
- AddValue (name, value, typeof (System.UInt64));
- }
-
- public void AddValue (string name, object value)
- {
- if (value == null)
- AddValue (name, value, typeof (System.Object));
- else
- AddValue (name, value, value.GetType ());
- }
-
- public bool GetBoolean (string name)
- {
- object value = GetValue (name, typeof (System.Boolean));
- return converter.ToBoolean (value);
- }
-
- public byte GetByte (string name)
- {
- object value = GetValue (name, typeof (System.Byte));
- return converter.ToByte (value);
- }
-
- public char GetChar (string name)
- {
- object value = GetValue (name, typeof (System.Char));
- return converter.ToChar (value);
- }
-
- public DateTime GetDateTime (string name)
- {
- object value = GetValue (name, typeof (System.DateTime));
- return converter.ToDateTime (value);
- }
-
- public Decimal GetDecimal (string name)
- {
- object value = GetValue (name, typeof (System.Decimal));
- return converter.ToDecimal (value);
- }
-
- public double GetDouble (string name)
- {
- object value = GetValue (name, typeof (System.Double));
- return converter.ToDouble (value);
- }
-
- public short GetInt16 (string name)
- {
- object value = GetValue (name, typeof (System.Int16));
- return converter.ToInt16 (value);
- }
-
- public int GetInt32 (string name)
- {
- object value = GetValue (name, typeof (System.Int32));
- return converter.ToInt32 (value);
- }
-
- public long GetInt64 (string name)
- {
- object value = GetValue (name, typeof (System.Int64));
- return converter.ToInt64 (value);
- }
-
- [CLSCompliant(false)]
- public SByte GetSByte (string name)
- {
- object value = GetValue (name, typeof (System.SByte));
- return converter.ToSByte (value);
- }
-
- public float GetSingle (string name)
- {
- object value = GetValue (name, typeof (System.Single));
- return converter.ToSingle (value);
- }
-
- public string GetString (string name)
- {
- object value = GetValue (name, typeof (System.String));
- if (value == null) return null;
- return converter.ToString (value);
- }
-
- [CLSCompliant(false)]
- public UInt16 GetUInt16 (string name)
- {
- object value = GetValue (name, typeof (System.UInt16));
- return converter.ToUInt16 (value);
- }
-
- [CLSCompliant(false)]
- public UInt32 GetUInt32 (string name)
- {
- object value = GetValue (name, typeof (System.UInt32));
- return converter.ToUInt32 (value);
- }
- [CLSCompliant(false)]
- public UInt64 GetUInt64 (string name)
- {
- object value = GetValue (name, typeof (System.UInt64));
- return converter.ToUInt64 (value);
- }
-
- /* used by the runtime */
-#pragma warning disable 169
- private SerializationEntry [] get_entries ()
- {
- SerializationEntry [] res = new SerializationEntry [this.MemberCount];
- int i = 0;
-
- foreach (SerializationEntry e in this)
- res [i++] = e;
-
- return res;
- }
-#pragma warning restore 169
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.SerializationInfoEnumerator.cs
-//
-// Author: Duncan Mak (duncan@ximian.com)
-//
-// (C) Ximian, Inc.
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-
-namespace System.Runtime.Serialization
-{
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public sealed class SerializationInfoEnumerator : IEnumerator
- {
- IEnumerator enumerator;
-
- // Constructor
- internal SerializationInfoEnumerator (IEnumerable list)
- {
- this.enumerator = list.GetEnumerator ();
- }
-
- // Properties
- public SerializationEntry Current
- {
- get { return (SerializationEntry) enumerator.Current; }
- }
-
- object IEnumerator.Current
- {
- get { return enumerator.Current; }
- }
-
- public string Name
- {
- get { return this.Current.Name; }
- }
-
- public Type ObjectType
- {
- get { return this.Current.ObjectType; }
- }
-
- public object Value
- {
- get { return this.Current.Value; }
- }
-
- // Methods
- public bool MoveNext ()
- {
- return enumerator.MoveNext ();
- }
-
- public void Reset ()
- {
- enumerator.Reset ();
- }
- }
-}
+++ /dev/null
-//
-// System.Runtime.Serialization.SerializationObjectManager.cs
-//
-// Author:
-// Robert Jordan (robertj@gmx.net)
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-
-namespace System.Runtime.Serialization {
-
- public sealed class SerializationObjectManager
- {
- readonly StreamingContext context;
- readonly Hashtable seen = new Hashtable (HashHelper.Instance, HashHelper.Instance);
-
- event SerializationCallbacks.CallbackHandler callbacks;
-
- public SerializationObjectManager (StreamingContext context)
- {
- this.context = context;
- }
-
- public void RegisterObject (object obj)
- {
- if (seen.Contains (obj))
- return;
-
- SerializationCallbacks sc = SerializationCallbacks
- .GetSerializationCallbacks (obj.GetType ());
-
- seen [obj] = HashHelper.NonNullObject;
- sc.RaiseOnSerializing (obj, context);
-
- if (sc.HasSerializedCallbacks) {
- // record for later invocation
- callbacks += delegate (StreamingContext ctx)
- {
- sc.RaiseOnSerialized (obj, ctx);
- };
- }
- }
-
- public void RaiseOnSerializedEvent ()
- {
- if (callbacks != null)
- callbacks (context);
- }
-
- class HashHelper : IHashCodeProvider, IComparer {
- public static object NonNullObject = new object ();
- public static HashHelper Instance = new HashHelper ();
-
- private HashHelper ()
- {
- }
-
- public int GetHashCode (object obj)
- {
- if (obj == null)
- return 0;
- return Object.InternalGetHashCode (obj);
- }
-
- public int Compare (object x, object y)
- {
- return Object.ReferenceEquals (x, y) ? 0 : 1;
- }
- }
- }
-}
-
+++ /dev/null
-//
-// System.Runtime.Serialization.StreamingContext.cs
-//
-// Author:
-// Miguel de Icaza (miguel@ximian.com)
-//
-// (C) Ximian, Inc. http://www.ximian.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.Serialization {
-
- [Serializable]
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- [StructLayout (LayoutKind.Sequential)]
- public struct StreamingContext {
- StreamingContextStates state;
- object additional;
-
- public StreamingContext (StreamingContextStates state)
- {
- this.state = state;
- additional = null;
- }
-
- public StreamingContext (StreamingContextStates state, object additional)
- {
- this.state = state;
- this.additional = additional;
- }
-
- public object Context {
- get {
- return additional;
- }
- }
-
- public StreamingContextStates State {
- get {
- return state;
- }
- }
-
- override public bool Equals (Object obj)
- {
- StreamingContext other;
-
- if (!(obj is StreamingContext))
- return false;
-
- other = (StreamingContext) obj;
-
- return (other.state == this.state) && (other.additional == this.additional);
- }
-
- override public int GetHashCode ()
- {
- return (int) state;
- }
- }
-}
+++ /dev/null
-// StreamingContextStates.cs
-//
-// This code was automatically generated from
-// ECMA CLI XML Library Specification.
-// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
-// Created: Wed, 5 Sep 2001 06:45:18 UTC
-// Source file: all.xml
-// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-namespace System.Runtime.Serialization {
-
-
- /// <summary>
- /// </summary>
- [Flags]
- [Serializable]
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public enum StreamingContextStates {
-
- /// <summary>
- /// </summary>
- CrossProcess = 1,
-
- /// <summary>
- /// </summary>
- CrossMachine = 2,
-
- /// <summary>
- /// </summary>
- File = 4,
-
- /// <summary>
- /// </summary>
- Persistence = 8,
-
- /// <summary>
- /// </summary>
- Remoting = 16,
-
- /// <summary>
- /// </summary>
- Other = 32,
-
- /// <summary>
- /// </summary>
- Clone = 64,
-
- CrossAppDomain = 128,
-
- /// <summary>
- /// </summary>
- All = 255,
- } // StreamingContextStates
-
-} // System.Runtime.Serialization
+++ /dev/null
-//
-// System.Runtime.Serialization.SurrogateSelector.cs
-//
-// Author: Duncan Mak (duncan@ximian.com)
-// Lluis Sanchez (lsg@ctv.es)
-//
-// (C) Ximian, Inc.
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-
-namespace System.Runtime.Serialization
-{
- [System.Runtime.InteropServices.ComVisibleAttribute (true)]
- public class SurrogateSelector : ISurrogateSelector
- {
- // Fields
- Hashtable Surrogates = new Hashtable ();
- ISurrogateSelector nextSelector = null;
-
- // Constructor
- public SurrogateSelector()
- : base ()
- {
- }
-
- // Methods
- public virtual void AddSurrogate (Type type,
- StreamingContext context, ISerializationSurrogate surrogate)
- {
- if (type == null || surrogate == null)
- throw new ArgumentNullException ("Null reference.");
-
- string currentKey = type.FullName + "#" + context.ToString ();
-
- if (Surrogates.ContainsKey (currentKey))
- throw new ArgumentException ("A surrogate for " + type.FullName + " already exists.");
-
- Surrogates.Add (currentKey, surrogate);
- }
-
- public virtual void ChainSelector (ISurrogateSelector selector)
- {
- if (selector == null)
- throw new ArgumentNullException ("Selector is null.");
-
- // Chain the selector at the beggining of the chain
- // since "The last selector added to the list will be the first one checked"
- // (from MS docs)
-
- if (nextSelector != null)
- selector.ChainSelector (nextSelector);
-
- nextSelector = selector;
- }
-
- public virtual ISurrogateSelector GetNextSelector ()
- {
- return nextSelector;
- }
-
- public virtual ISerializationSurrogate GetSurrogate (Type type,
- StreamingContext context, out ISurrogateSelector selector)
- {
- if (type == null)
- throw new ArgumentNullException ("type is null.");
-
- // Check this selector, and if the surrogate is not found,
- // check the chained selectors
-
- string key = type.FullName + "#" + context.ToString ();
- ISerializationSurrogate surrogate = (ISerializationSurrogate) Surrogates [key];
-
- if (surrogate != null) {
- selector = this;
- return surrogate;
- }
-
- if (nextSelector != null)
- return nextSelector.GetSurrogate (type, context, out selector);
- else {
- selector = null;
- return null;
- }
- }
-
- public virtual void RemoveSurrogate (Type type, StreamingContext context)
- {
- if (type == null)
- throw new ArgumentNullException ("type is null.");
-
- string key = type.FullName + "#" + context.ToString ();
- Surrogates.Remove (key);
- }
- }
-}
return CreateInstance (elementType, length);
}
+ internal static Array UnsafeCreateInstance(Type elementType, int[] lengths, int[] lowerBounds)
+ {
+ return CreateInstance(elementType, lengths, lowerBounds);
+ }
+
+ internal static Array UnsafeCreateInstance (Type elementType, int length1, int length2)
+ {
+ return CreateInstance (elementType, length1, length2);
+ }
+
+ internal static Array UnsafeCreateInstance (Type elementType, params int[] lengths)
+ {
+ return CreateInstance(elementType, lengths);
+ }
+
public static Array CreateInstance (Type elementType, int length)
{
int[] lengths = {length};
return RemotingServices.IsTransparentProxy (m_target);
#endif
}
+
+ internal static Delegate CreateDelegateNoSecurityCheck (RuntimeType type, Object firstArgument, MethodInfo method)
+ {
+ return CreateDelegate_internal (type, firstArgument, method, true);
+ }
}
}
realTarget = info.GetValue (target.ToString(), typeof(object));
var key = "method" + index;
- var method = info.HasKey (key) ? (MethodInfo)info.GetValue (key, typeof (MethodInfo)) : null;
+ var method = (MethodInfo)info.GetValueNoThrow (key, typeof(MethodInfo));
Assembly dasm = Assembly.Load (assembly);
Type dt = dasm.GetType (type);
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
+using System.Runtime.CompilerServices;
namespace System
{
{
return !left.Equals (right);
}
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ static extern void SetValueInternal (FieldInfo fi, object obj, object value);
+
+ internal static void SetValue (RtFieldInfo field, Object obj, Object value, RuntimeType fieldType, FieldAttributes fieldAttr, RuntimeType declaringType, ref bool domainInitialized)
+ {
+ SetValueInternal (field, obj, value);
+ }
}
}
}
}
+ namespace NestedA
+ {
+ [Serializable]
+ public class QualifiedFieldTest
+ {
+ int value = 0;
+
+ public int ValueA {
+ get { return value; }
+ set { this.value = value; }
+ }
+ }
+ }
+
+ namespace NestedB
+ {
+ [Serializable]
+ public class QualifiedFieldTest : NestedA.QualifiedFieldTest
+ {
+ int value = 0;
+
+ public int ValueB {
+ get { return value; }
+ set { this.value = value; }
+ }
+ }
+ }
+
+ [Serializable]
+ public class QualifiedFieldTest : NestedB.QualifiedFieldTest
+ {
+ int value = 0;
+
+ public int Value {
+ get { return value; }
+ set { this.value = value; }
+ }
+ }
+
class SurrogateSelector: ISurrogateSelector
{
public void ChainSelector (ISurrogateSelector selector)
return ms;
}
+ [Test]
+ public void QualifiedField()
+ {
+ QualifiedFieldTest a = new QualifiedFieldTest ();
+ a.ValueA = 1;
+ a.ValueB = 2;
+ a.Value = 3;
+ Stream ms = new MemoryStream ();
+ BinaryFormatter bf = new BinaryFormatter ();
+ bf.Serialize(ms, a);
+ ms.Position = 0;
+ QualifiedFieldTest b = (QualifiedFieldTest)bf.Deserialize (ms);
+ Assert.AreEqual (a.ValueA, b.ValueA, "#1");
+ Assert.AreEqual (a.ValueB, b.ValueB, "#2");
+ Assert.AreEqual (a.Value, b.Value, "#3");
+ }
+
#if NET_4_0
[Test]
public void SerializationBindToName ()
System.Runtime.Remoting.Services/EnterpriseServicesHelper.cs
System.Runtime.Remoting.Services/ITrackingHandler.cs
System.Runtime.Remoting.Services/TrackingServices.cs
-System.Runtime.Serialization/Formatter.cs
-System.Runtime.Serialization/FormatterConverter.cs
-System.Runtime.Serialization/FormatterServices.cs
-System.Runtime.Serialization/IDeserializationCallback.cs
-System.Runtime.Serialization/IFormatter.cs
-System.Runtime.Serialization/IFormatterConverter.cs
-System.Runtime.Serialization/IObjectReference.cs
-System.Runtime.Serialization/ISafeSerializationData.cs
-System.Runtime.Serialization/ISerializable.cs
-System.Runtime.Serialization/ISerializationSurrogate.cs
-System.Runtime.Serialization/ISurrogateSelector.cs
-System.Runtime.Serialization/ObjectIDGenerator.cs
-System.Runtime.Serialization/ObjectManager.cs
-System.Runtime.Serialization/OnDeserializedAttribute.cs
-System.Runtime.Serialization/OnDeserializingAttribute.cs
-System.Runtime.Serialization/OnSerializedAttribute.cs
-System.Runtime.Serialization/OnSerializingAttribute.cs
-System.Runtime.Serialization/OptionalFieldAttribute.cs
-System.Runtime.Serialization/SafeSerializationEventArgs.cs
-System.Runtime.Serialization/SerializationBinder.cs
-System.Runtime.Serialization/SerializationCallbacks.cs
-System.Runtime.Serialization/SerializationEntry.cs
-System.Runtime.Serialization/SerializationException.cs
-System.Runtime.Serialization/SerializationInfo.cs
-System.Runtime.Serialization/SerializationInfoEnumerator.cs
-System.Runtime.Serialization/SerializationObjectManager.cs
-System.Runtime.Serialization/StreamingContext.cs
-System.Runtime.Serialization/StreamingContextStates.cs
-System.Runtime.Serialization/SurrogateSelector.cs
-System.Runtime.Serialization.Formatters/FormatterAssemblyStyle.cs
-System.Runtime.Serialization.Formatters/FormatterTopObjectStyle.cs
-System.Runtime.Serialization.Formatters/FormatterTypeStyle.cs
-System.Runtime.Serialization.Formatters/IFieldInfo.cs
-System.Runtime.Serialization.Formatters/InternalArrayTypeE.cs
-System.Runtime.Serialization.Formatters/InternalElementTypeE.cs
-System.Runtime.Serialization.Formatters/InternalMemberTypeE.cs
-System.Runtime.Serialization.Formatters/InternalMemberValueE.cs
-System.Runtime.Serialization.Formatters/InternalNameSpaceE.cs
-System.Runtime.Serialization.Formatters/InternalObjectPositionE.cs
-System.Runtime.Serialization.Formatters/InternalObjectTypeE.cs
-System.Runtime.Serialization.Formatters/InternalParseStateE.cs
-System.Runtime.Serialization.Formatters/InternalParseTypeE.cs
-System.Runtime.Serialization.Formatters/InternalPrimitiveTypeE.cs
-System.Runtime.Serialization.Formatters/InternalRM.cs
-System.Runtime.Serialization.Formatters/InternalSerializerTypeE.cs
-System.Runtime.Serialization.Formatters/InternalST.cs
-System.Runtime.Serialization.Formatters/ISoapMessage.cs
-System.Runtime.Serialization.Formatters/ServerFault.cs
-System.Runtime.Serialization.Formatters/SoapFault.cs
-System.Runtime.Serialization.Formatters/SoapMessage.cs
-System.Runtime.Serialization.Formatters/TypeFilterLevel.cs
-System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs
-System.Runtime.Serialization.Formatters.Binary/BinaryCommon.cs
-System.Runtime.Serialization.Formatters.Binary/CodeGenerator.cs
-System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs
-System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs
-System.Runtime.Serialization.Formatters.Binary/MessageFormatter.cs
System.Runtime.Versioning/CompatibilitySwitch.cs
System.Runtime.Versioning/ComponentGuaranteesAttribute.cs
System.Runtime.Versioning/ComponentGuaranteesOptions.cs
ReferenceSources/EncodingTable.cs
ReferenceSources/TypeNameParser.cs
ReferenceSources/RuntimeType.cs
+ReferenceSources/RemotingFieldCachedData.cs
+ReferenceSources/MessageDictionary.cs
../../../external/referencesource/mscorlib/system/__filters.cs
../../../external/referencesource/mscorlib/system/__hresults.cs
../../../external/referencesource/mscorlib/system/text/stringbuildercache.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/deserializationeventhandler.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatterconverter.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatterservices.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/ideserializationcallback.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/iformatter.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/iformatterconverter.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/iobjectreference.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/iserializable.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/iserializationsurrogate.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/isurrogateselector.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/memberholder.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/objectclonehelper.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/objectidgenerator.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/safeserializationmanager.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/serializationattributes.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/serializationbinder.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/serializationeventscache.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/serializationexception.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/serializationfieldinfo.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/serializationinfo.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/serializationinfoenumerator.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/serializationobjectmanager.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/streamingcontext.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/surrogateselector.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/valuetypefixupinfo.cs
+
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binarycommonclasses.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryconverter.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryenums.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatterwriter.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binarymethodmessage.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectinfo.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectreader.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectwriter.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryparser.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryutilclasses.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/commonenums.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/ifieldinfo.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/isoapmessage.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/sertrace.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/soapfault.cs
+../../../external/referencesource/mscorlib/system/runtime/serialization/formatters/soapmessage.cs
+
../../../external/referencesource/mscorlib/system/threading/abandonedmutexexception.cs
../../../external/referencesource/mscorlib/system/threading/apartmentstate.cs
../../../external/referencesource/mscorlib/system/threading/autoresetevent.cs
ICALL(REMSER_2, "IsTransparentProxy", ves_icall_IsTransparentProxy)
#endif
+ICALL_TYPE(RFH, "System.RuntimeFieldHandle", RFH_1)
+ICALL(RFH_1, "SetValueInternal", ves_icall_MonoField_SetValueInternal)
+
ICALL_TYPE(MHAN, "System.RuntimeMethodHandle", MHAN_1)
ICALL(MHAN_1, "GetFunctionPointer", ves_icall_RuntimeMethod_GetFunctionPointer)