Exemple #1
0
        internal RemoteFunctionBind(RemoteFunctionInfomation _info, Delegate _functionCall)
        {
            FunctionInfo = _info;
            SetAuthFunc(null);

            FuctionCall = _functionCall;
            if (FuctionCall == null)
            {
                throw new ArgumentNullException("_functionCall");
            }
        }
Exemple #2
0
        /// <summary>
        /// Binds a function to be accessable through remote calling. NOT THREAD SAFE.
        /// </summary>
        /// <param name="name">Name of the function to be caled by</param>
        /// <param name="a">Function to bind</param>
        /// <returns>Function infomation</returns>
        public RemoteFunctionBind BindRemoteCall(string name, Delegate a)
        {
            if (FunctionLookup.ContainsKey(name))
            {
                throw new Exception("Function with the same name alredy exists");
            }

            var funcInfo = new RemoteFunctionInfomation();

            funcInfo.Name = name;

            if (!BindableTypes.ContainsKey(a.Method.ReturnType))
            {
                throw new Exception("Return type is not seralizable.");
            }

            var funcParamInfo = a.Method.GetParameters();

            funcInfo.ReturnType = BindableTypes[a.Method.ReturnType];
            funcInfo.Parameters = new uint[funcParamInfo.Length];

            for (int i = 0; i < funcParamInfo.Length; i++)
            {
                var t = funcParamInfo[i].ParameterType;
                if (!BindableTypes.ContainsKey(t))
                {
                    throw new Exception(string.Format("Parameter type {0} not seralizable.", t));
                }
                funcInfo.Parameters[i] = BindableTypes[t];
            }

            var remoteFunc = new RemoteFunctionBind(funcInfo, a);

            remoteFunc.SetAuthFunc(DefaultAuthCallback);
            FunctionLookup.Add(name, remoteFunc);
            return(remoteFunc);
        }