public ClientActionExecutingContext(Guid clientProxyId, IServiceProvider serviceProvider, string?optionsName, IOnceCall onceCall, InstanceMethod instanceMethod, Func <object?, Task>?callback, CancellationToken token, ContractInfo contract, ContractMethod contractMethod, ReadStream?stream, Dictionary <string, object?> header, object?[] pureArgs) { ClientProxyId = clientProxyId; StartTime = DateTimeOffset.Now; ServiceProvider = serviceProvider; OnceCall = onceCall; InstanceMethod = instanceMethod; Callback = callback; Contract = contract; ContractMethod = contractMethod; CancellationToken = token; Stream = stream; PureArgs = pureArgs; OptionsName = optionsName; Header = header; }
public ActionExecutingContext(IServiceProvider serviceProvider, Dictionary <string, object?> header, Instance instance, MethodInfo instanceMethodInfo, ContractMethod contractMethod, object?[] args, object?[] pureArgs, ActionInfo actionInfo, ProxyStream?stream, ContractInfo contract, ChannelType channelType, Func <object?, Task>?callback, CancellationToken token) { Properties = new Dictionary <object, object?>(); StartTime = DateTimeOffset.Now; ServiceProvider = serviceProvider; ChannelType = channelType; Header = header; InstanceMethod = instance.Methods.Find(i => i.MethodInfo == instanceMethodInfo) !; ContractMethod = contractMethod; Instance = instance; Args = args; PureArgs = pureArgs; CallbackType = GetFuncType(args); ActionInfo = actionInfo; Callback = callback; Stream = stream; Contract = contract; CancellationToken = token; ResetProps(); }
public Instance(ContractInfo contract, object target) { Contract = contract; Target = target; Type = target.GetType(); foreach (var m in Type.GetMethods()) { Methods.Add(new InstanceMethod(m, target)); } }
public static ContractInfo GetOrAdd <T>() { var type = typeof(T); lock (LockObj) { if (Dic.TryGetValue(type, out var value)) { return(value); } var newInfo = new ContractInfo(type); Dic.Add(type, newInfo); return(newInfo); } }
public Call(Guid clientProxyId, IServiceProvider serviceProvider, ContractInfo contract, IOnceCallFactory factory, int timeoutInterval, string optionsName) { _clientProxyId = clientProxyId; _serviceProvider = serviceProvider; _contract = contract; _factory = factory; _timeoutInterval = timeoutInterval; _optionsName = optionsName; if (serviceProvider != null) { var middlewareOptions = _serviceProvider.GetService <IOptions <ClientMiddlewareOptions> >().Value; _middlewareBuilder = new ClientMiddlewareBuilder(middlewareOptions, serviceProvider); } }
public Call(Guid clientProxyId, ContractInfo contractInfo, IServiceProvider serviceProvider, ClientMiddlewareOptions middlewareOptions, IActionExecutingContextAccessor actionExecutingContextAccessor, IOnceCallFactory factory, int timeoutInterval, bool forwardHeader, string?optionsName) { _clientProxyId = clientProxyId; _serviceProvider = serviceProvider; _actionExecutingContextAccessor = actionExecutingContextAccessor; _contract = contractInfo; _factory = factory; _timeoutInterval = timeoutInterval; _forwardHeader = forwardHeader; _optionsName = optionsName; _middlewareBuilder = new ClientMiddlewareBuilder(middlewareOptions, serviceProvider); }
private static (MethodInfo instanceMethodInfo, ContractMethod contractMethod) GetMethodInfo(ActionInfo action, ContractInfo contract, object instance) { var methodObj = contract.Methods.FirstOrDefault(i => i.MethodInfo.ToFullMethodName() == action.FullName); if (methodObj != null) { var instanceMethodInfo = instance.GetType().GetMethod(methodObj.MethodInfo.Name) !; if (action.GenericArguments.Length > 0) { var ts = action.GenericArguments.ToList().ConvertAll(Type.GetType).ToArray(); // ReSharper disable once PossibleNullReferenceException instanceMethodInfo = instanceMethodInfo.MakeGenericMethod(ts !); } return(instanceMethodInfo, methodObj); } return(default);
public Contract(Type contractType, Func <IServiceProvider, object> instanceFactory) { _instanceFactory = instanceFactory; ContractInfo = new ContractInfo(contractType); }
public Contract(Type contractType, Type instanceType) { InstanceType = instanceType; ContractInfo = new ContractInfo(contractType); }