當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。