public string RpcToProxyGroupString(RpcEntity entity, int tableNum) { if (entity.ReturnType.TypeType != FieldType.Void) { return(null); } StringBuilder sb = new StringBuilder(); sb.NewLine(tableNum).AppendFormat("public void {0}(IEnumerable<LibActor.ActorID> IDs, ", entity.Name.Value); if (entity.Param != null) { sb.AppendFormat("{0} {1}", TypeToString(entity.Param.Type), entity.Param.Name.Value); } sb.Append(" )"); sb.NewLine(tableNum).Append("{"); if (entity.Param != null) { sb.NewLine(tableNum + 1).AppendFormat("actor.SendMessage({0}, IDs, {1});", entity.Param.Name.Value, MsgIdToString(entity.ID)); } if (entity.Param == null) { sb.NewLine(tableNum + 1).AppendFormat("actor.SendMessage(IDs, {1});", MsgIdToString(entity.ID)); } sb.NewLine(tableNum).Append("}"); return(sb.ToString()); }
public string RpcToProxyString(RpcEntity entity, int tableNum) { StringBuilder sb = new StringBuilder(); sb.NewLine(tableNum).AppendFormat("public void {0}(LibActor.ActorID ID, ", entity.Name.Value); if (entity.Param != null) { sb.AppendFormat("{0} {1}", TypeToString(entity.Param.Type), entity.Param.Name.Value); } if (entity.ReturnType.TypeType != FieldType.Void) { if (entity.Param != null) { sb.Append(", "); } sb.AppendFormat("Action<LibActor.ActorID, {0}> handle", TypeToString(entity.ReturnType)); } sb.Append(" )"); sb.NewLine(tableNum).Append("{"); if (entity.ReturnType.TypeType != FieldType.Void) { if (entity.Param == null) { sb.NewLine(tableNum + 1).AppendFormat("int responid = actor.MsgHandle.AddHandle({0}, ID, handle);", MsgIdToString(entity.ID)); } else { sb.NewLine(tableNum + 1).AppendFormat("int responid = actor.MsgHandle.AddHandle({0}, ID, {1}, handle);", MsgIdToString(entity.ID), entity.Param.Name.Value); } } if (entity.Param != null && entity.ReturnType.TypeType != FieldType.Void) { sb.NewLine(tableNum + 1).AppendFormat("actor.SendMessage({0}, ID, {1}, responid);", entity.Param.Name.Value, MsgIdToString(entity.ID)); } if (entity.Param == null && entity.ReturnType.TypeType != FieldType.Void) { sb.NewLine(tableNum + 1).AppendFormat("actor.SendMessage(ID, {0}, responid);", MsgIdToString(entity.ID)); } if (entity.Param != null && entity.ReturnType.TypeType == FieldType.Void) { sb.NewLine(tableNum + 1).AppendFormat("actor.SendMessage({0}, ID, {1});", entity.Param.Name.Value, MsgIdToString(entity.ID)); } if (entity.Param == null && entity.ReturnType.TypeType == FieldType.Void) { sb.NewLine(tableNum + 1).AppendFormat("actor.SendMessage(ID, {1});", MsgIdToString(entity.ID)); } sb.NewLine(tableNum).Append("}"); return(sb.ToString()); }
public string RpcToServiceString(RpcEntity entity, int tableNum) { StringBuilder sb = new StringBuilder(); sb.NewLine(tableNum).AppendFormat("{0} {1}(LibActor.ActorID from", TypeToString(entity.ReturnType), entity.Name.Value); if (entity.Param != null) { sb.AppendFormat(", {0} {1}", TypeToString(entity.Param.Type), entity.Param.Name.Value); } sb.Append(");"); /* * sb.NewLine(tableNum).Append("{"); * sb.NewLine(tableNum + 1).Append("throw new NotImplementedException();"); * sb.NewLine(tableNum).Append("}"); */ return(sb.ToString()); }
public string RpcToRegistString(RpcEntity entity) { StringBuilder sb = new StringBuilder(); sb.Append("actor.MsgHandle.AddHandle"); if (entity.Param != null) { if (entity.ReturnType.TypeType == FieldType.Void) { sb.Append("<").Append(TypeToString(entity.ReturnType)).Append(">"); } else { sb.AppendFormat("<{0}, {1}>", TypeToString(entity.Param.Type), TypeToString(entity.ReturnType)); } } sb.AppendFormat("({0}, service.{1});", MsgIdToString(entity.ID), entity.Name.Value); return(sb.ToString()); }