当前位置: 首页>>代码示例>>C#>>正文


C# Serialization.ErrorContext类代码示例

本文整理汇总了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;
    }
开发者ID:runegri,项目名称:Applicable,代码行数:7,代码来源:JsonSerializerInternalBase.cs

示例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;
 }
开发者ID:dannisliang,项目名称:FFEngine,代码行数:10,代码来源:JsonNetSerializer.cs

示例3: HandleError

 internal void HandleError(StreamingContext context, ErrorContext errorContext)
 {
     if (errorContext.Member.Equals("rpi"))
     {
         (errorContext.OriginalObject as RigListRecords).rpi = double.NaN;
         errorContext.Handled = true;
     }
 }
开发者ID:bitbandi,项目名称:MiningRigRentalsApi,代码行数:8,代码来源:RigDetailsResponse.cs

示例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;
    }
开发者ID:runegri,项目名称:Applicable,代码行数:10,代码来源:JsonSerializerInternalBase.cs

示例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;
 }
开发者ID:cloudsdaleapp,项目名称:cloudsdale-wp7,代码行数:15,代码来源:User.cs

示例6: OnDerivedErrorMethod

 internal void OnDerivedErrorMethod(StreamingContext context, ErrorContext errorContext)
 {
 }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:3,代码来源:SerializationEventTestObject.cs

示例7: OnError

 internal void OnError(StreamingContext context, ErrorContext errorContext)
 {
 }
开发者ID:TheHunter,项目名称:Newtonsoft.Json,代码行数:3,代码来源:SerializationErrorHandlingTests.cs

示例8: HandleError

 internal void HandleError(StreamingContext context, ErrorContext errorContext)
 {
   errorContext.Handled = true;
 }
开发者ID:pvasek,项目名称:Newtonsoft.Json,代码行数:4,代码来源:PersonError.cs

示例9: OnErrorMethod

 internal void OnErrorMethod(StreamingContext context, ErrorContext errorContext)
 {
   Member5 = "Error message for member " + errorContext.Member + " = " + errorContext.Error.Message;
   errorContext.Handled = true;
 }
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:5,代码来源:SerializationEventTestObject.cs

示例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");
            }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:12,代码来源:SerializationEventAttributeTests.cs

示例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);
         }
     }
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:12,代码来源:JsonContract.cs

示例12: ErrorEventArgs

 public ErrorEventArgs(object currentObject, ErrorContext errorContext)
 {
   this.CurrentObject = currentObject;
   this.ErrorContext = errorContext;
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:5,代码来源:ErrorEventArgs.cs

示例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;
            }
开发者ID:JamesNK,项目名称:Newtonsoft.Json,代码行数:9,代码来源:SerializationEventAttributeTests.cs

示例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;
 }
开发者ID:CragonGame,项目名称:GameCloud.IM,代码行数:10,代码来源:ErrorEventArgs.cs

示例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
     });
 }
开发者ID:fuboss,项目名称:aiProject,代码行数:14,代码来源:JsonNetSerializer.cs


注:本文中的Newtonsoft.Json.Serialization.ErrorContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。