本文整理汇总了C#中Newtonsoft.Json.Serialization.ErrorContext类的典型用法代码示例。如果您正苦于以下问题:C# ErrorContext类的具体用法?C# ErrorContext怎么用?C# ErrorContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorContext类属于Newtonsoft.Json.Serialization命名空间,在下文中一共展示了ErrorContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearErrorContext
protected void ClearErrorContext()
{
if (_currentErrorContext == null)
throw new InvalidOperationException("Could not clear error context. Error context is already null.");
_currentErrorContext = null;
}
示例2: FormatError
/// <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;
}
示例3: HandleError
internal void HandleError(StreamingContext context, ErrorContext errorContext)
{
if (errorContext.Member.Equals("rpi"))
{
(errorContext.OriginalObject as RigListRecords).rpi = double.NaN;
errorContext.Handled = true;
}
}
示例4: GetErrorContext
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;
}
示例5: OnError
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;
}
示例6: OnDerivedErrorMethod
internal void OnDerivedErrorMethod(StreamingContext context, ErrorContext errorContext)
{
}
示例7: OnError
internal void OnError(StreamingContext context, ErrorContext errorContext)
{
}
示例8: HandleError
internal void HandleError(StreamingContext context, ErrorContext errorContext)
{
errorContext.Handled = true;
}
示例9: OnErrorMethod
internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext)
{
Member5 = "Error message for member " + errorContext.Member + " = " + errorContext.Error.Message;
errorContext.Handled = true;
}
示例10: OnError
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");
}
示例11: InvokeOnError
// 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);
}
}
}
示例12: ErrorEventArgs
public ErrorEventArgs(object currentObject, ErrorContext errorContext)
{
this.CurrentObject = currentObject;
this.ErrorContext = errorContext;
}
示例13: OnError
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;
}
示例14: ErrorEventArgs
/// <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;
}
示例15: FormatError
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
});
}