public RenamedItem(NanoXmlElement el, RenamedClass owner)
    {
      try
      {
        this.owner = owner;
        entityType = (EntityType)Enum.Parse(typeof (EntityType), el.Name.Substring(7));
        string str = el.GetAttribute("oldName");

        int i;
        if ((i = str.IndexOf(' ')) != -1)
        {
          string s = str.Substring(0, i);
          int k = s.IndexOf('/');
          if (k != -1)
            resultType = new Renamed(s.Substring(0, k) + "." + s.Substring(k + 1));
          else
            resultType = new Renamed(s);
          str = str.Substring(i + 1);
        }

        if ((i = str.IndexOf("::")) != -1)
          str = str.Substring(i + 2);

        if ((i = str.IndexOf('(')) != -1)
        {
          methodParams = new List<Renamed>();
          foreach (string s in EntityName.ParseList(str, i + 1, ')'))
          {
            int k = s.IndexOf('/');
            if (k != -1)
              methodParams.Add(new Renamed(s.Substring(0, k) + "." + s.Substring(k + 1)));
            else
              methodParams.Add(new Renamed(s));
          }

          str = str.Substring(0, i);

          i = str.IndexOf('[');
          if (i != -1 && str[i + 2] == ']')
            str = str.Substring(0, i);
        }

        string strNew = el.GetAttribute("newName");
        if (strNew != "dropped")
          name = new Renamed(str, strNew);
        else
          name = new Renamed(str);
      }
      catch (Exception e)
      {
        throw new ObfuscarParserException("Failed to process item element", e, el.Path);
      }
    }
        private void ParseClass(NanoXmlElement el, Mapping owner)
        {
            try
            {
                string newName = el.GetAttribute("newName");
                int    j       = newName.IndexOf('/');
                if (j != -1)
                {
                    newName = newName.Substring(j + 1);
                }

                string str = el.GetAttribute("oldName");

                j = str.IndexOf('/');
                if (j != -1)
                {
                    ownerClassName = str.Substring(0, j);
                    name           = new Renamed(str.Substring(j + 1), newName);
                }
                else
                {
                    name = new Renamed(str, newName);
                }
            }
            catch (Exception e)
            {
                throw new ObfuscarParserException("Failed to process class element: ", e, el.Path);
            }

            foreach (NanoXmlElement element in el.ChildElements)
            {
                if (!element.Name.StartsWith("renamed"))
                {
                    continue;
                }

                items.Add(new RenamedItem(element, this));
            }
        }
        private void ParseSkipped(NanoXmlElement el)
        {
            try
            {
                string str = el.GetAttribute("name");

                int j = str.IndexOf('/');
                if (j != -1)
                {
                    ownerClassName = str.Substring(0, j);
                    name           = new Renamed(str.Substring(j + 1));
                }
                else
                {
                    name = new Renamed(str);
                }

                skipReason = el.GetAttribute("reason");
            }
            catch (Exception e)
            {
                throw new ObfuscarParserException("Failed to process element", e, el.Path);
            }
        }
Ejemplo n.º 4
0
        public RenamedItem(NanoXmlElement el, RenamedClass owner)
        {
            try
            {
                this.owner = owner;
                entityType = (EntityType)Enum.Parse(typeof(EntityType), el.Name.Substring(7));
                string str = el.GetAttribute("oldName");

                int i;
                if ((i = str.IndexOf(' ')) != -1)
                {
                    string s = str.Substring(0, i);
                    int    k = s.IndexOf('/');
                    if (k != -1)
                    {
                        resultType = new RenamedParam(s.Substring(0, k) + "." + s.Substring(k + 1));
                    }
                    else
                    {
                        resultType = new RenamedParam(s);
                    }
                    str = str.Substring(i + 1);
                }

                if ((i = str.IndexOf("::")) != -1)
                {
                    str = str.Substring(i + 2);
                }

                if ((i = str.IndexOf('(')) != -1)
                {
                    methodParams = new List <RenamedParam>();
                    foreach (string s in EntityName.ParseList(str, i + 1, ')'))
                    {
                        int k = s.IndexOf('/');
                        if (k != -1)
                        {
                            methodParams.Add(new RenamedParam(s.Substring(0, k) + "." + s.Substring(k + 1)));
                        }
                        else
                        {
                            methodParams.Add(new RenamedParam(s));
                        }
                    }

                    str = str.Substring(0, i);

                    i = str.IndexOf('[');
                    if (i != -1 && str[i + 2] == ']')
                    {
                        str = str.Substring(0, i);
                    }
                }

                string strNew = el.GetAttribute("newName");
                if (strNew != "dropped")
                {
                    name = new Renamed(str, strNew);
                }
                else
                {
                    name = new Renamed(str);
                }
            }
            catch (Exception e)
            {
                throw new ObfuscarParserException("Failed to process item element", e, el.Path);
            }
        }