Ejemplo n.º 1
0
        private static List <EntityName> BuildParams(ref string s)
        {
            int i = s.IndexOf('(');

            if (i == -1)
            {
                return(null);
            }

            List <EntityName> result = new List <EntityName>();
            int paramStart           = i;

            i++; // skip (

            int j = s.IndexOf(')');

            if (j != -1)
            {
                j = j - i;
            }
            else
            {
                j = s.Length - i;
            }
            if (j != 0)
            {
                string[] p = s.Substring(i, j).Split(',');
                foreach (string s1 in p)
                {
                    string s2 = s1.Trim(' ');
                    int    k  = s2.IndexOf(' ');
                    if (k != -1)
                    {
                        s2 = s2.Substring(0, k);
                    }

                    result.Add(RenamedParam.ParseParam(s2));
                }
            }

            s = s.Substring(0, paramStart);
            return(result);
        }
Ejemplo n.º 2
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);
            }
        }