CreateSerializationErrorCallback() static private method

static private CreateSerializationErrorCallback ( MethodInfo callbackMethodInfo ) : SerializationErrorCallback
callbackMethodInfo System.Reflection.MethodInfo
return SerializationErrorCallback
Example #1
0
 private void GetCallbackMethodsForType(Type type, out List <SerializationCallback> onSerializing, out List <SerializationCallback> onSerialized, out List <SerializationCallback> onDeserializing, out List <SerializationCallback> onDeserialized, out List <SerializationErrorCallback> onError)
 {
     onSerializing   = null;
     onSerialized    = null;
     onDeserializing = null;
     onDeserialized  = null;
     onError         = null;
     foreach (Type current in this.GetClassHierarchyForType(type))
     {
         MethodInfo   currentCallback  = null;
         MethodInfo   currentCallback2 = null;
         MethodInfo   currentCallback3 = null;
         MethodInfo   currentCallback4 = null;
         MethodInfo   currentCallback5 = null;
         MethodInfo[] methods          = current.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
         for (int i = 0; i < methods.Length; i++)
         {
             MethodInfo methodInfo = methods[i];
             if (!methodInfo.ContainsGenericParameters)
             {
                 Type            type2      = null;
                 ParameterInfo[] parameters = methodInfo.GetParameters();
                 if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnSerializingAttribute), currentCallback, ref type2))
                 {
                     onSerializing = (onSerializing ?? new List <SerializationCallback>());
                     onSerializing.Add(JsonContract.CreateSerializationCallback(methodInfo));
                     currentCallback = methodInfo;
                 }
                 if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnSerializedAttribute), currentCallback2, ref type2))
                 {
                     onSerialized = (onSerialized ?? new List <SerializationCallback>());
                     onSerialized.Add(JsonContract.CreateSerializationCallback(methodInfo));
                     currentCallback2 = methodInfo;
                 }
                 if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnDeserializingAttribute), currentCallback3, ref type2))
                 {
                     onDeserializing = (onDeserializing ?? new List <SerializationCallback>());
                     onDeserializing.Add(JsonContract.CreateSerializationCallback(methodInfo));
                     currentCallback3 = methodInfo;
                 }
                 if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnDeserializedAttribute), currentCallback4, ref type2))
                 {
                     onDeserialized = (onDeserialized ?? new List <SerializationCallback>());
                     onDeserialized.Add(JsonContract.CreateSerializationCallback(methodInfo));
                     currentCallback4 = methodInfo;
                 }
                 if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnErrorAttribute), currentCallback5, ref type2))
                 {
                     onError = (onError ?? new List <SerializationErrorCallback>());
                     onError.Add(JsonContract.CreateSerializationErrorCallback(methodInfo));
                     currentCallback5 = methodInfo;
                 }
             }
         }
     }
 }