示例#1
0
 public static ServiceEntity ParseServiceEntity(TokenIterator it)
 {
     if (!ServiceMatch.Match(it))
     {
         return(null);
     }
     do
     {
         ServiceEntity entity = new ServiceEntity();
         if (!VarNameMatch.Match(it, ref entity.Name) || !OpeningbraceMatch.Match(it))
         {
             break;
         }
         while (true)
         {
             if (CloseingbraceMatch.Match(it))
             {
                 break;
             }
             var rpcEntity = ParseRpcEntiy(it);
             if (rpcEntity == null)
             {
                 return(null);
             }
             entity.Rpcs.Add(rpcEntity);
         }
         return(entity);
     } while (false);
     throw new Exception(ItToError(it));
 }
示例#2
0
        public static bool Check(this ServiceEntity entity, string nameSpace)
        {
            if (entity.Name == null)
            {
                return(false);
            }
            var token = FindName(nameSpace, entity.Name);

            if (token != null)
            {
                Console.WriteLine(string.Format("{0} => service name has exist in {1}", entity.Name, token));
                return(false);
            }
            for (int i = 0; i < entity.Rpcs.Count; ++i)
            {
                var rpc = entity.Rpcs[i];
                if (!rpc.Check(nameSpace, entity.Name.Value))
                {
                    return(false);
                }
                for (int j = i + 1; j < entity.Rpcs.Count; ++j)
                {
                    if (rpc.Name.Value == entity.Rpcs[j].Name.Value)
                    {
                        Console.WriteLine(string.Format("{0} => rpc name has exist in {1}", entity.Rpcs[j].Name, rpc.Name));
                        return(false);
                    }
                }
            }
            return(true);
        }