public RenamedClass SearchForNewName(EntityName target)
        {
            if (name.NameNew != null)
            {
                if (target.Compare(NameNew))
                {
                    return(this);
                }
                if (target.Compare(NameNewFull))
                {
                    return(this);
                }
            }

            foreach (RenamedBase item in items)
            {
                if (item.EntityType != EntityType.Class)
                {
                    continue;
                }

                RenamedClass c = (RenamedClass)item;
                c = c.SearchForNewName(target);
                if (c != null)
                {
                    return(c);
                }
            }

            return(null);
        }
Esempio n. 2
0
        public RenamedItem(IMappingEntity reader, RenamedClass owner)
        {
            this.owner = owner;

            try
            {
                this.owner = owner;
                entityType = reader.Type;
                string str = reader.Name;

                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 = reader.NewName;
                if (strNew != "dropped")
                {
                    name = new Renamed(str, strNew);
                }
                else
                {
                    name = new Renamed(str);
                }

                skipReason = reader.SkipReason;
                if (name.NameOld.Name == "ctor")
                {
                    entityType = EntityType.Constructor;
                }
            }
            catch (Exception e)
            {
                throw new ObfuscarParserException("Failed to process item element", e, reader.Path);
            }
        }