Newtonsoft.Json.Serialization.JsonContract.InvokeOnError C# (CSharp) Method

InvokeOnError() private method

private InvokeOnError ( object o, StreamingContext context, Newtonsoft.Json.Serialization.ErrorContext errorContext ) : void
o object
context System.Runtime.Serialization.StreamingContext
errorContext Newtonsoft.Json.Serialization.ErrorContext
return void
        internal void InvokeOnError(object o, StreamingContext context, ErrorContext errorContext)
        {
            if (_onErrorCallbacks != null)
            {
                foreach (SerializationErrorCallback callback in _onErrorCallbacks)
                {
                    callback(o, context, errorContext);
                }
            }
        }

Usage Example

Esempio n. 1
0
        protected bool IsErrorHandled(object currentObject, JsonContract contract, object keyValue, IJsonLineInfo lineInfo, [Nullable(1)] string path, [Nullable(1)] Exception ex)
        {
            ErrorContext errorContext = this.GetErrorContext(currentObject, keyValue, path, ex);

            if (this.TraceWriter != null && this.TraceWriter.LevelFilter >= TraceLevel.Error && !errorContext.Traced)
            {
                errorContext.Traced = true;
                string text = (base.GetType() == typeof(JsonSerializerInternalWriter)) ? "Error serializing" : "Error deserializing";
                if (contract != null)
                {
                    string str            = text;
                    string str2           = " ";
                    Type   underlyingType = contract.UnderlyingType;
                    text = str + str2 + ((underlyingType != null) ? underlyingType.ToString() : null);
                }
                text = text + ". " + ex.Message;
                if (!(ex is JsonException))
                {
                    text = JsonPosition.FormatMessage(lineInfo, path, text);
                }
                this.TraceWriter.Trace(TraceLevel.Error, text, ex);
            }
            if (contract != null && currentObject != null)
            {
                contract.InvokeOnError(currentObject, this.Serializer.Context, errorContext);
            }
            if (!errorContext.Handled)
            {
                this.Serializer.OnError(new ErrorEventArgs(currentObject, errorContext));
            }
            return(errorContext.Handled);
        }
All Usage Examples Of Newtonsoft.Json.Serialization.JsonContract::InvokeOnError