static ExplicitParamsModifierCache() { FieldInfo?idInjectField = null; foreach (var field in typeof(TParams).GetFields(BindingFlags.Public | BindingFlags.NonPublic)) { if (field.GetCustomAttribute <RpcIDAttribute>() is null) { continue; } else { idInjectField = field; break; } } if (idInjectField is null) { ModifierType = typeof(EmptyModifier <TParams>); } else { ModifierType = RpcMethodEntryFactoryBuildingHelper.CreateIdInjecter(typeof(TParams).FullName + ".IdInjecter", idInjectField, typeof(TParams)); } }
static RpcExplicitParamsFuncDelegateEntryFactory() { if (typeof(TResult).IsConstructedGenericType) { var genericType = typeof(TResult).GetGenericTypeDefinition(); if (genericType == typeof(Task <>)) { Instance = RpcMethodEntryFactoryBuildingHelper.CreateEntryFactory <Func <TParams, TResult> >(typeof(RpcAsyncDelegateEntryFactory <, , , , ,>), typeof(TParams), typeof(TResult).GetGenericArguments()[0], typeof(ExplicitParamsObjectDeserializer <TParams>), ExplicitParamsModifierCache <TParams> .ModifierType, typeof(ExplicitParamsTaskFuncDelegateInvoker <TParams, TResult>)); } else { if (genericType == typeof(ValueTask <>)) { Instance = RpcMethodEntryFactoryBuildingHelper.CreateEntryFactory <Func <TParams, TResult> >(typeof(RpcAsyncDelegateEntryFactory <, , , , ,>), typeof(TParams), typeof(TResult).GetGenericArguments()[0], typeof(ExplicitParamsObjectDeserializer <TParams>), ExplicitParamsModifierCache <TParams> .ModifierType, typeof(ExplicitParamsFuncDelegateInvoker <TParams, TResult>)); } else { Instance = RpcMethodEntryFactoryBuildingHelper.CreateEntryFactory <Func <TParams, TResult> >(typeof(RpcDelegateEntryFactory <, , , , ,>), typeof(TParams), typeof(TResult), typeof(ExplicitParamsObjectDeserializer <TParams>), ExplicitParamsModifierCache <TParams> .ModifierType, typeof(ExplicitParamsFuncDelegateInvoker <TParams, TResult>)); } } } else { if (typeof(TResult) == typeof(Task)) { Instance = RpcMethodEntryFactoryBuildingHelper.CreateAsyncActionEntryFactory <Func <TParams, TResult> >(typeof(RpcAsyncDelegateEntryFactory <, , , ,>), typeof(TParams), typeof(ExplicitParamsObjectDeserializer <TParams>), ExplicitParamsModifierCache <TParams> .ModifierType, typeof(ExplicitParamsTaskActionDelegateInvoker <TParams>)); } else { if (typeof(TResult) == typeof(ValueTask)) { Instance = RpcMethodEntryFactoryBuildingHelper.CreateAsyncActionEntryFactory <Func <TParams, TResult> >(typeof(RpcAsyncDelegateEntryFactory <, , , ,>), typeof(TParams), typeof(ExplicitParamsObjectDeserializer <TParams>), ExplicitParamsModifierCache <TParams> .ModifierType, typeof(ExplicitParamsFuncDelegateInvoker <TParams, ValueTask>)); } else { Instance = RpcMethodEntryFactoryBuildingHelper.CreateEntryFactory <Func <TParams, TResult> >(typeof(RpcDelegateEntryFactory <, , , , ,>), typeof(TParams), typeof(TResult), typeof(ExplicitParamsObjectDeserializer <TParams>), ExplicitParamsModifierCache <TParams> .ModifierType, typeof(ExplicitParamsFuncDelegateInvoker <TParams, TResult>)); } } } }
static RpcExplicitParamsActionDelegateEntryFactory() { Instance = RpcMethodEntryFactoryBuildingHelper.CreateEntryFactory <Action <TParams> >(typeof(RpcDelegateEntryFactory <, , , , ,>), typeof(TParams), typeof(NullResult), typeof(ExplicitParamsObjectDeserializer <TParams>), ExplicitParamsModifierCache <TParams> .ModifierType, typeof(ExplicitParamsActionDelegateInvoker <TParams>)); }