internal RemoteFunctionBind(RemoteFunctionInformation info, Delegate functionCall) { _functionInfo = info; SetAuthFunc(null); _functionCall = functionCall; if (_functionCall == null) { throw new ArgumentNullException(nameof(functionCall)); } }
public RemoteFunctionBind BindRemoteCall(string name, Delegate a) { if (_functionLookup.ContainsKey(name)) { throw new Exception("Function with the same name already exists"); } RemoteFunctionInformation funcInfo = new RemoteFunctionInformation { Name = name }; if (!_bindableTypes.ContainsKey(a.Method.ReturnType)) { throw new Exception("Return type is not serializable."); } ParameterInfo[] funcParamInfo = a.Method.GetParameters(); funcInfo.ReturnType = _bindableTypes[a.Method.ReturnType]; funcInfo.Parameters = new uint[funcParamInfo.Length]; for (int i = 0; i < funcParamInfo.Length; i++) { Type t = funcParamInfo[i].ParameterType; if (!_bindableTypes.ContainsKey(t)) { throw new Exception($"Parameter type {t} not serializable."); } funcInfo.Parameters[i] = _bindableTypes[t]; } RemoteFunctionBind remoteFunc = new RemoteFunctionBind(funcInfo, a); remoteFunc.SetAuthFunc(_defaultAuthCallback); _functionLookup.Add(name, remoteFunc); return(remoteFunc); }