IsValidCallback() private static method

private static IsValidCallback ( MethodInfo method, ParameterInfo parameters, Type attributeType, MethodInfo currentCallback, Type &prevAttributeType ) : bool
method System.Reflection.MethodInfo
parameters System.Reflection.ParameterInfo
attributeType System.Type
currentCallback System.Reflection.MethodInfo
prevAttributeType System.Type
return bool
Ejemplo n.º 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;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void GetCallbackMethodsForType(Type type, out MethodInfo onSerializing, out MethodInfo onSerialized, out MethodInfo onDeserializing, out MethodInfo onDeserialized, out MethodInfo onError)
 {
     onSerializing   = null;
     onSerialized    = null;
     onDeserializing = null;
     onDeserialized  = null;
     onError         = null;
     MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
     for (int i = 0; i < (int)methods.Length; i++)
     {
         MethodInfo methodInfo = methods[i];
         if (!methodInfo.ContainsGenericParameters)
         {
             Type            type1      = null;
             ParameterInfo[] parameters = methodInfo.GetParameters();
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnSerializingAttribute), onSerializing, ref type1))
             {
                 onSerializing = methodInfo;
             }
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnSerializedAttribute), onSerialized, ref type1))
             {
                 onSerialized = methodInfo;
             }
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnDeserializingAttribute), onDeserializing, ref type1))
             {
                 onDeserializing = methodInfo;
             }
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnDeserializedAttribute), onDeserialized, ref type1))
             {
                 onDeserialized = methodInfo;
             }
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnErrorAttribute), onError, ref type1))
             {
                 onError = methodInfo;
             }
         }
     }
 }
 private void GetCallbackMethodsForType(Type type, out MethodInfo onSerializing, out MethodInfo onSerialized, out MethodInfo onDeserializing, out MethodInfo onDeserialized, out MethodInfo onError)
 {
     onSerializing   = null;
     onSerialized    = null;
     onDeserializing = null;
     onDeserialized  = null;
     onError         = null;
     MethodInfo[] methods = type.GetMethods(54);
     for (int i = 0; i < methods.Length; i++)
     {
         MethodInfo methodInfo = methods[i];
         if (!methodInfo.get_ContainsGenericParameters())
         {
             Type            type2      = null;
             ParameterInfo[] parameters = methodInfo.GetParameters();
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnSerializingAttribute), onSerializing, ref type2))
             {
                 onSerializing = methodInfo;
             }
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnSerializedAttribute), onSerialized, ref type2))
             {
                 onSerialized = methodInfo;
             }
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnDeserializingAttribute), onDeserializing, ref type2))
             {
                 onDeserializing = methodInfo;
             }
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnDeserializedAttribute), onDeserialized, ref type2))
             {
                 onDeserialized = methodInfo;
             }
             if (DefaultContractResolver.IsValidCallback(methodInfo, parameters, typeof(OnErrorAttribute), onError, ref type2))
             {
                 onError = methodInfo;
             }
         }
     }
 }
Ejemplo n.º 4
0
 private void GetCallbackMethodsForType(Type type, out MethodInfo onSerializing, out MethodInfo onSerialized, out MethodInfo onDeserializing, out MethodInfo onDeserialized, out MethodInfo onError)
 {
     onSerializing   = (MethodInfo)null;
     onSerialized    = (MethodInfo)null;
     onDeserializing = (MethodInfo)null;
     onDeserialized  = (MethodInfo)null;
     onError         = (MethodInfo)null;
     foreach (MethodInfo method in type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
     {
         if (!method.ContainsGenericParameters)
         {
             Type            prevAttributeType = (Type)null;
             ParameterInfo[] parameters        = method.GetParameters();
             if (DefaultContractResolver.IsValidCallback(method, parameters, typeof(OnSerializingAttribute), onSerializing, ref prevAttributeType))
             {
                 onSerializing = method;
             }
             if (DefaultContractResolver.IsValidCallback(method, parameters, typeof(OnSerializedAttribute), onSerialized, ref prevAttributeType))
             {
                 onSerialized = method;
             }
             if (DefaultContractResolver.IsValidCallback(method, parameters, typeof(OnDeserializingAttribute), onDeserializing, ref prevAttributeType))
             {
                 onDeserializing = method;
             }
             if (DefaultContractResolver.IsValidCallback(method, parameters, typeof(OnDeserializedAttribute), onDeserialized, ref prevAttributeType))
             {
                 onDeserialized = method;
             }
             if (DefaultContractResolver.IsValidCallback(method, parameters, typeof(OnErrorAttribute), onError, ref prevAttributeType))
             {
                 onError = method;
             }
         }
     }
 }