private RpcBind getRpcBind(UInt32 rpcIdValue)
        {
            RpcBind rpcBind = null;

            _receiveRpcMap.TryGetValue(rpcIdValue, out rpcBind);
            return(rpcBind);
        }
        private void initRpcs()
        {
            Type currentType            = GetType();
            RpcClassAttribute classAttr =
                Attribute.GetCustomAttribute(currentType, typeof(RpcClassAttribute)) as RpcClassAttribute;

            if (classAttr == null)
            {
                throw new MessageException("RpcClassAttribute NOT FOUND!");
            }

            MethodInfo[] methods = currentType.GetMethods(BindingFlags.Public |
                                                          BindingFlags.NonPublic | BindingFlags.Instance);

            for (int i = 0, count = methods.Length; i < count; ++i)
            {
                MethodInfo mi = methods[i];
                if (Attribute.IsDefined(mi, typeof(RpcForwardAttribute)))
                {
                    string rpcName = makeRpcName(classAttr.className, mi.Name, mi.GetParameters().Length);
                    RpcId  rpcId   = new RpcId(rpcName);
                    _forwardRpcIdMap.Add(mi.Name, rpcId);
                }
                else if (Attribute.IsDefined(mi, typeof(RpcReceiveAttribute)))
                {
                    string  rpcName = makeRpcName(classAttr.className, mi.Name, mi.GetParameters().Length);
                    RpcId   rpcId   = new RpcId(rpcName);
                    RpcBind rpcBind = new RpcBind(rpcId, mi);
                    _receiveRpcMap.Add(rpcId.value, rpcBind);
                }
            }
        }
        public bool receive(out RpcId rpcId, UInt32 rpcIdValue, InputStream inputStream)
        {
            RpcBind rpcBind = getRpcBind(rpcIdValue);

            if (rpcBind == null)
            {
                rpcId = null;
                return(false);
            }
            rpcId = rpcBind.rpcId;
            rpcBind.execute(this, inputStream);
            return(true);
        }
Beispiel #4
0
        void ServiceInit()
        {
            RPCBind = RPCClient.CreateBind(Guid.Parse("367abb81-9844-35f1-ad32-98f038001003"), 2, 0, false, true);
            //OpenSCManagerW
            int retCode = new OpenSCManagerW(RPCBind).EXEC(IpAddress, out byte[] scHandle);

            if (retCode == 0)
            {
                SCHandle = scHandle;
            }
            else
            {
                throw new Exception("OpenSCManagerW error " + retCode);
            }
        }