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 RpcServicePair(string sServerNamespace, string sClientNamespace, IServiceAttribute hServerAttrib, IServiceAttribute hClientAttrib) { Server = new RpcService(sServerNamespace, this, hClientAttrib.Service, hServerAttrib, ".Service"); Client = new RpcService(sClientNamespace, this, hServerAttrib.Service, hClientAttrib, ".Protocol"); Client.Generate(); Server.Generate(); SharedCode = new List<string>(); SharedCode.AddRange(Server.Rpcs.Select(hM => hM.Request.Code)); SharedCode.AddRange(Server.Rpcs.Where(hM => hM.Response != null).Select(hM => hM.Response.Code)); SharedCode.AddRange(Server.Rpcs.Where(hM => hM.ResponseAction != null).Select(hM => hM.ResponseAction.Code)); SharedCode.AddRange(Client.Rpcs.Select(hM => hM.Request.Code)); SharedCode.AddRange(Client.Rpcs.Where(hM => hM.Response != null).Select(hM => hM.Response.Code)); SharedCode.AddRange(Client.Rpcs.Select(hM => hM.RequestAction.Code)); SharedCode.Add(new ClientSessionCodeGen(Client).Code); SharedCode.Add(new NonBlockingClientSessionCodeGen(Client).Code); ServiceCode = new List<string>(); ServiceCode.AddRange(Server.Rpcs.Select(hM => hM.RequestAction.Code)); ServiceCode.AddRange(Client.Rpcs.Where(hM => hM.ResponseAction != null).Select(hM => hM.ResponseAction.Code)); ServiceCode.Add(new ServerCodeGen(Server).Code); ServiceCode.Add(new ServerSessionCodeGen(Server).Code); }