Exemplo n.º 1
0
        public RpcMethodInfo(RpcService hService, MethodInfo hMethod)
        {
            Method      = hMethod;
            Attribute   = hMethod.GetCustomAttribute<ServiceOperation>();
            if (Attribute == null)
                throw new MissingAttributeException("Missing ServiceOperation Attribute on Method " + hMethod.Name);

            Service     = hService;

            if (Attribute.Type == RpcType.OneWay && hMethod.ReturnType != typeof(void))
                throw new Exception("OneWay Rpc's require void return type, check method signature " + hMethod.Name);

            Request     = new RequestCodeGen(this, Service.Pair.ProtocolCounter);
            Service.Pair.ProtocolCounter++;

            if (Attribute.Type == RpcType.TwoWay)
            {
                Response = new ResponseCodeGen(this, Service.Pair.ProtocolCounter);
                Service.Pair.ProtocolCounter++;
            }

            if (hService.Attribute is ServiceContract && Attribute.Type == RpcType.OneWay)
            {
                RequestAction = new RequestActionCodeGen(new OneWayServerReqActionBuilder(), this);
            }
            else if (hService.Attribute is ServiceContract)
            {
                ResponseAction = new ResponseActionCodeGen(new ServerResActionBuilder(), this);
                RequestAction  = new RequestActionCodeGen(new TwoWayServerReqActionBuilder(), this);
            }
            else if (hService.Attribute is CallbackContract && Attribute.Type == RpcType.OneWay)
            {
                RequestAction = new RequestActionCodeGen(new OneWayClientReqActionBuilder(), this);
            }
            else
            {
                ResponseAction = new ResponseActionCodeGen(new ClientResActionBuilder(), this);
                RequestAction = new RequestActionCodeGen(new TwoWayClientReqActionBuilder(), this);
            }
        }
 public string ResponseDeclaration(ResponseCodeGen hResponse)
 {
     return string.Empty;
 }
 public string ResponseDeclaration(ResponseCodeGen hResponse)
 {
     return string.Format("private {0} m_hResponse;", hResponse.RpcInfo.Response.Name);
 }
 public string ResponseAllocation(ResponseCodeGen hResponse)
 {
     return string.Empty;
 }
 public string ResponseAllocation(ResponseCodeGen hResponse)
 {
     return string.Format("m_hResponse = new {0}();", hResponse.RpcInfo.Response.Name);
 }