protected void ClearErrorContext() { if (_currentErrorContext == null) throw new InvalidOperationException("Could not clear error context. Error context is already null."); _currentErrorContext = null; }
/// <summary> /// Formats an ErrorContext for pretty printing. /// </summary> private static string FormatError(ErrorContext error) { return "Attempting to recover from serialization error\n" + error.Error.Message + "\n" + "Member: " + error.Member + "\n" + "OriginalObject: " + error.OriginalObject + "\n" + "Exception: " + error.Error; }
internal void HandleError(StreamingContext context, ErrorContext errorContext) { if (errorContext.Member.Equals("rpi")) { (errorContext.OriginalObject as RigListRecords).rpi = double.NaN; errorContext.Handled = true; } }
protected ErrorContext GetErrorContext(object currentObject, object member, Exception error) { if (_currentErrorContext == null) _currentErrorContext = new ErrorContext(currentObject, member, error); if (_currentErrorContext.Error != error) throw new InvalidOperationException("Current error context error is different to requested error."); return _currentErrorContext; }
internal void OnError(StreamingContext context, ErrorContext errorContext) { var model = errorContext.OriginalObject; var modelType = model.GetType(); var memberName = errorContext.Member.ToString(); var field = modelType.GetField(memberName); if (field.FieldType == typeof(DateTime?)) { field.SetValue(model, DateTime.MaxValue); } else if (field.FieldType == typeof(string)) { field.SetValue(model, ""); } else { field.SetValue(model, null); } errorContext.Handled = true; }
private static string FormatError(ErrorContext error) { return string.Concat(new object[] { "Attempting to recover from serialization error\n", error.Error.Message, "\nMember: ", error.Member, "\nOriginalObject: ", error.OriginalObject, "\nException: ", error.Error }); }
internal void OnError(StreamingContext context, ErrorContext errorContext) { }
internal void HandleError(StreamingContext context, ErrorContext errorContext) { errorContext.Handled = true; }
internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext) { Member5 = "Error message for member " + errorContext.Member + " = " + errorContext.Error.Message; errorContext.Handled = true; }
private void OnError(StreamingContext context, ErrorContext error) { Identifier = 25; // Here we could for example manually copy the // persisted "Id" value into the renamed "Identifier" // property, etc. error.Handled = true; // We never get here :( Console.WriteLine("Error has been fixed"); }
internal void InvokeOnError(object o, StreamingContext context, ErrorContext errorContext) { if (_onErrorCallbacks != null) { foreach (SerializationErrorCallback callback in _onErrorCallbacks) { callback(o, context, errorContext); } } }
public ErrorEventArgs(object currentObject, ErrorContext errorContext) { this.CurrentObject = currentObject; this.ErrorContext = errorContext; }
private void OnError(StreamingContext context, ErrorContext error) { Identifier = 25; // Here we could for example manually copy the // persisted "Id" value into the renamed "Identifier" // property, etc. error.Handled = true; }
/// <summary> /// Initializes a new instance of the <see cref="ErrorEventArgs"/> class. /// </summary> /// <param name="currentObject">The current object.</param> /// <param name="errorContext">The error context.</param> public ErrorEventArgs(object currentObject, ErrorContext errorContext) { CurrentObject = currentObject; ErrorContext = errorContext; }
internal void InvokeOnError(object o, StreamingContext context, ErrorContext errorContext) { if (this.OnError == null) return; this.OnError.Invoke(o, new object[2] { (object) context, (object) errorContext }); }
// Token: 0x060002AA RID: 682 // RVA: 0x0002F160 File Offset: 0x0002D360 internal void InvokeOnError(object o, StreamingContext context, ErrorContext errorContext) { if (this._onErrorCallbacks != null) { foreach (SerializationErrorCallback current in this._onErrorCallbacks) { current(o, context, errorContext); } } }
internal void InvokeOnError(object o, StreamingContext context, ErrorContext errorContext) { foreach (MethodInfo mi in OnErrorMethods) { mi.Invoke(o, new object[] {context, errorContext}); } }
internal void InvokeOnError(object o, ErrorContext errorContext) { if (OnError != null) OnError.Invoke(o, new object[] { SerializationStreamingContextParameter, errorContext }); }
internal void OnDerivedErrorMethod(StreamingContext context, ErrorContext errorContext) { }
internal void InvokeOnError(object o, StreamingContext context, ErrorContext errorContext) { if (OnError != null) OnError.Invoke(o, new object[] { context, errorContext }); }
public JsonSerializationException(ErrorContext[] errors) { Errors = errors; }