/// <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="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 = _methodName } ); }
/// <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 } ); }
void DoSerialize(object sender, SafeSerializationEventArgs e) { if (_exceptionData != null) { e.AddSerializedState(new SerialData() { ExData = _exceptionData }); } }
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. // The constructor isn't run on deserialization, so we have to provide the empty state to get a // deserialization event, which we use to hook serialization back up on the new object. eventArgs.AddSerializedState(new EmptyState()); }
/// <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="SafeSerializationEventArgs"/> instance containing the event data. /// The overriding method adds its internal state to this object via <see cref="M:SafeSerializationEventArgs.AddSerializedState"/>. /// </param> /// <remarks> /// The overriding method MUST invoke base implementation, or the serialization should fail. /// </remarks> /// <seealso cref="ISafeSerializationData"/> protected virtual void OnSerializeObjectState(object sender, SafeSerializationEventArgs e) { e.AddSerializedState( new SerializedState() { DebugInformation = debugInformation, RemoteExceptions = remoteExceptions, RpcErrorIdentifier = rpcError.Identifier, RpcErrorCode = rpcError.ErrorCode, PreservedStackTrace = _preservedStackTrace } ); }
private static void HandleSerialization(object exception, SafeSerializationEventArgs eventArgs) { eventArgs.AddSerializedState(new SerializableExceptionState(exception)); }