示例#1
0
 private static void HandleSerialization(object exception, SafeSerializationEventArgs eventArgs)
 {
     // Nothing to do here, since we don't have any additional state. But setting the event is required in order
     // to enable serialization. Note that we use the .NET 4 safe-serialization rather than the old
     // ISerializable.
     // Also note that we use a static delegate since we don't have any instance state.
 }
 internal void CompleteSerialization(object serializedObject, SerializationInfo info, StreamingContext context)
 {
     this.m_serializedStates = null;
     EventHandler<SafeSerializationEventArgs> serializeObjectState = this.SerializeObjectState;
     if (serializeObjectState != null)
     {
         SafeSerializationEventArgs e = new SafeSerializationEventArgs(context);
         serializeObjectState(serializedObject, e);
         this.m_serializedStates = e.SerializedStates;
         info.AddValue("CLR_SafeSerializationManager_RealType", serializedObject.GetType(), typeof(RuntimeType));
         info.SetType(typeof(SafeSerializationManager));
     }
 }
示例#3
0
        internal void CompleteSerialization(object serializedObject, SerializationInfo info, StreamingContext context)
        {
            this.m_serializedStates = null;
            EventHandler <SafeSerializationEventArgs> serializeObjectState = this.SerializeObjectState;

            if (serializeObjectState != null)
            {
                SafeSerializationEventArgs e = new SafeSerializationEventArgs(context);
                serializeObjectState(serializedObject, e);
                this.m_serializedStates = e.SerializedStates;
                info.AddValue("CLR_SafeSerializationManager_RealType", serializedObject.GetType(), typeof(RuntimeType));
                info.SetType(typeof(SafeSerializationManager));
            }
        }
        internal void CompleteSerialization(object serializedObject, SerializationInfo info, StreamingContext context)
        {
            this.m_serializedStates = (IList <object>)null;
            // ISSUE: reference to a compiler-generated field
            EventHandler <SafeSerializationEventArgs> eventHandler = this.SerializeObjectState;

            if (eventHandler == null)
            {
                return;
            }
            SafeSerializationEventArgs e = new SafeSerializationEventArgs(context);

            eventHandler(serializedObject, e);
            this.m_serializedStates = e.SerializedStates;
            info.AddValue("CLR_SafeSerializationManager_RealType", (object)serializedObject.GetType(), typeof(RuntimeType));
            info.SetType(typeof(SafeSerializationManager));
        }
        internal void CompleteSerialization(object serializedObject,
                                            SerializationInfo info,
                                            StreamingContext context)
        {
            Contract.Requires(serializedObject != null);
            Contract.Requires(info != null);
            Contract.Requires(typeof(ISerializable).IsAssignableFrom(serializedObject.GetType()));
            Contract.Requires(serializedObject.GetType().IsAssignableFrom(info.ObjectType));

            // Clear out any stale state
            m_serializedStates = null;

            // We only want to kick in our special serialization sauce if someone wants to participate in
            // it, otherwise if we have no delegates registered there's no reason for us to get in the way
            // of the regular serialization machinery.
            EventHandler<SafeSerializationEventArgs> serializeObjectStateEvent = SerializeObjectState;
            if (serializeObjectStateEvent != null)
            {
                // Get any extra data to add to our serialization state now
                SafeSerializationEventArgs eventArgs = new SafeSerializationEventArgs(context);
                serializeObjectStateEvent(serializedObject, eventArgs);
                m_serializedStates = eventArgs.SerializedStates;

                // Replace the type to be deserialized by the standard serialization code paths with
                // ourselves, which allows us to control the deserialization process.
                info.AddValue(RealTypeSerializationName, serializedObject.GetType(), typeof(RuntimeType));
                info.SetType(typeof(SafeSerializationManager));
            } 
        }
示例#6
0
		/// <summary>
		///		When overridden on the derived class, handles <see cref="E:Exception.SerializeObjectState"/> event to add type-specified serialization state.
		/// </summary>
		/// <param name="sender">The <see cref="Exception"/> instance itself.</param>
		/// <param name="e">
		///		The <see cref="System.Runtime.Serialization.SafeSerializationEventArgs"/> instance containing the event data.
		///		The overriding method adds its internal state to this object via <see cref="M:SafeSerializationEventArgs.AddSerializedState"/>.
		///	</param>
		/// <seealso cref="ISafeSerializationData"/>
		protected override void OnSerializeObjectState( object sender, SafeSerializationEventArgs e )
		{
			base.OnSerializeObjectState( sender, e );
			e.AddSerializedState(
				new SerializedState()
				{
					ClientTimeout = this._clientTimeout
				}
			);
		}
示例#7
0
			private static void HandleSerialization (object exception, SafeSerializationEventArgs eventArgs) {
				eventArgs.AddSerializedState (new SerializableExceptionState (exception));
			}
示例#8
0
 void DoSerialize( object sender, SafeSerializationEventArgs e )
 {
     if( _exceptionData != null ) e.AddSerializedState( new SerialData() { ExData = _exceptionData } );
 }
示例#9
0
		/// <summary>
		///		When overridden on the derived class, handles <see cref="E:Exception.SerializeObjectState"/> event to add type-specified serialization state.
		/// </summary>
		/// <param name="sender">The <see cref="Exception"/> instance itself.</param>
		/// <param name="e">
		///		The <see cref="System.Runtime.Serialization.SafeSerializationEventArgs"/> instance containing the event data.
		///		The overriding method adds its internal state to this object via <see cref="M:SafeSerializationEventArgs.AddSerializedState"/>.
		///	</param>
		/// <seealso cref="ISafeSerializationData"/>
		protected override void OnSerializeObjectState( object sender, SafeSerializationEventArgs e )
		{
			base.OnSerializeObjectState( sender, e );
			e.AddSerializedState(
				new SerializedState()
				{
					Error = this._error,
					ErrorDetail = this._errorDetail
				}
			);
		}
		/// <summary>
		///		When overridden on the derived class, handles <see cref="E:Exception.SerializeObjectState"/> event to add type-specified serialization state.
		/// </summary>
		/// <param name="sender">The <see cref="Exception"/> instance itself.</param>
		/// <param name="e">
		///		The <see cref="System.Runtime.Serialization.SafeSerializationEventArgs"/> instance containing the event data.
		///		The overriding method adds its internal state to this object via <see cref="M:SafeSerializationEventArgs.AddSerializedState"/>.
		///	</param>
		/// <seealso cref="ISafeSerializationData"/>
		protected override void OnSerializeObjectState( object sender, SafeSerializationEventArgs e )
		{
			base.OnSerializeObjectState( sender, e );
			e.AddSerializedState(
				new SerializedState()
				{
					MethodName = this._methodName
				}
			);
		}