Beispiel #1
0
        public static bool Check(this RpcEntity entity, string nameSpace, string serviceName)
        {
            if (!entity.ReturnType.Check(nameSpace))
            {
                return(false);
            }
            if (entity.Param != null)
            {
                if (!entity.Param.Type.Check(nameSpace))
                {
                    return(false);
                }
                if (entity.Param.Name.Value == "ID" || entity.Param.Name.Value == "IDs")
                {
                    Console.WriteLine(string.Format("{0} => rpc func name can't use ID or IDs", entity.Name));
                    return(false);
                }
            }
            string idName   = string.Format("RPC_{0}_{1}", serviceName, entity.Name.Value);
            var    idEntity = FindMsgIdEntity(nameSpace, idName);

            if (idEntity == null)
            {
                Console.WriteLine(string.Format("{0} => rpc need a ID enum in same namespace, like : RPC_service_rpcName", entity.Name));
                return(false);
            }
            entity.ID = idEntity;
            return(true);
        }
Beispiel #2
0
 public static RpcEntity ParseRpcEntiy(TokenIterator it)
 {
     if (!RpcMatch.Match(it))
     {
         return(null);
     }
     do
     {
         RpcEntity entity = new RpcEntity();
         entity.ReturnType = ParseTypeEntity(it);
         if (entity.ReturnType == null)
         {
             break;
         }
         if (!VarNameMatch.Match(it, ref entity.Name))
         {
             break;
         }
         ;
         if (!OpeningBracketMatch.Match(it))
         {
             break;
         }
         if (!CloseingBracketMatch.Match(it))
         {
             var paramEntity = ParseParamEntity(it);
             if (paramEntity == null)
             {
                 break;
             }
             entity.Param = paramEntity;
             if (!CloseingBracketMatch.Match(it))
             {
                 break;
             }
         }
         if (!SemicolonMatch.Match(it))
         {
             break;
         }
         return(entity);
     } while (false);
     throw new Exception(ItToError(it));
 }