protected virtual void Reflect()
{
IsClearedForBuffer = true;
rpcs = new Dictionary<int, KeyValuePair<MethodInfo, List<IBRPCIntercept>>>();
#if NETFX_CORE
IEnumerable<MethodInfo> methods = this.GetType().GetRuntimeMethods();
#else
MethodInfo[] methods = this.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
#endif
foreach (MethodInfo method in methods)
{
BRPC[] attributes = null;
#if NETFX_CORE
attributes = method.GetCustomAttributes<BRPC>().ToList().ToArray();
//if (method.GetCustomAttribute<BRPC>() != null)
#else
attributes = method.GetCustomAttributes(typeof(BRPC), true) as BRPC[];
#endif
if (attributes != null && attributes.Length != 0)
{
RPCs.Add(RPCs.Count, new KeyValuePair<MethodInfo, List<IBRPCIntercept>>(method, new List<IBRPCIntercept>()));
foreach (BRPC brpc in attributes)
{
if (brpc.interceptorType == null)
continue;
object interceptor = Activator.CreateInstance(brpc.interceptorType);
if (interceptor == null || !(interceptor is IBRPCIntercept))
throw new NetworkException("The type " + brpc.interceptorType.ToString() + " does not implement IBRPCIntercept");
RPCs[RPCs.Count - 1].Value.Add((IBRPCIntercept)interceptor);
}
}
}
}