Esempio n. 1
0
        public bool Remove(string str)
        {
            string htmlStr = String.Format(RazorHTMLFormat, str);

            /*for ( int i = 0; i < m_Content.Count; i++ )
             * {
             *      OPLEntry ent = (OPLEntry)m_Content[i];
             *      if ( ent == null )
             *              continue;
             *
             *      for (int s=0;s<m_DefaultStringNums.Length;s++)
             *      {
             *              if ( ent.Number == m_DefaultStringNums[s] && ( ent.Args == htmlStr || ent.Args == str ) )
             *              {
             *                      m_StringNums.Insert( 0, ent.Number );
             *
             *                      m_Content.RemoveAt( i );
             *
             *                      AddHash( ent.Number );
             *                      if ( ent.Args != null && ent.Args != "" )
             *                              AddHash( ent.Args.GetHashCode() );
             *                      return true;
             *              }
             *      }
             * }*/

            for (int i = 0; i < m_CustomContent.Count; i++)
            {
                OPLEntry ent = (OPLEntry)m_CustomContent[i];
                if (ent == null)
                {
                    continue;
                }

                for (int s = 0; s < m_DefaultStringNums.Length; s++)
                {
                    if (ent.Number == m_DefaultStringNums[s] && (ent.Args == htmlStr || ent.Args == str))
                    {
                        m_StringNums.Insert(0, ent.Number);

                        m_CustomContent.RemoveAt(i);

                        AddHash(ent.Number);
                        if (!string.IsNullOrEmpty(ent.Args))
                        {
                            AddHash(ent.Args.GetHashCode());
                        }
                        return(true);
                    }
                }
            }

            return(false);
        }
Esempio n. 2
0
        public void Read(PacketReader p)
        {
            m_Content.Clear();

            p.Seek(5, System.IO.SeekOrigin.Begin); // seek to packet data

            p.ReadUInt32();                        // serial
            p.ReadByte();                          // 0
            p.ReadByte();                          // 0
            m_Hash = p.ReadInt32();

            m_StringNums.Clear();
            m_StringNums.AddRange(m_DefaultStringNums);

            while (p.Position < p.Length)
            {
                int num = p.ReadInt32();
                if (num == 0)
                {
                    break;
                }

                m_StringNums.Remove(num);

                short  bytes = p.ReadInt16();
                string args  = null;
                if (bytes > 0)
                {
                    args = p.ReadUnicodeStringBE(bytes >> 1);
                }

                m_Content.Add(new OPLEntry(num, args));
            }

            for (int i = 0; i < m_CustomContent.Count; i++)
            {
                OPLEntry ent = (OPLEntry)m_CustomContent[i];
                if (m_StringNums.Contains(ent.Number))
                {
                    m_StringNums.Remove(ent.Number);
                }
                else
                {
                    for (int s = 0; s < m_DefaultStringNums.Length; s++)
                    {
                        if (ent.Number == m_DefaultStringNums[s])
                        {
                            ent.Number = GetStringNumber();
                            break;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public bool Remove(int number)
        {
            for (int i = 0; i < m_Content.Count; i++)
            {
                OPLEntry ent = (OPLEntry)m_Content[i];
                if (ent == null)
                {
                    continue;
                }

                if (ent.Number == number)
                {
                    for (int s = 0; s < m_DefaultStringNums.Length; s++)
                    {
                        if (m_DefaultStringNums[s] == ent.Number)
                        {
                            m_StringNums.Insert(0, ent.Number);
                            break;
                        }
                    }

                    m_Content.RemoveAt(i);
                    AddHash(ent.Number);
                    if (!string.IsNullOrEmpty(ent.Args))
                    {
                        AddHash(ent.Args.GetHashCode());
                    }

                    return(true);
                }
            }

            for (int i = 0; i < m_CustomContent.Count; i++)
            {
                OPLEntry ent = (OPLEntry)m_CustomContent[i];
                if (ent == null)
                {
                    continue;
                }

                if (ent.Number == number)
                {
                    for (int s = 0; s < m_DefaultStringNums.Length; s++)
                    {
                        if (m_DefaultStringNums[s] == ent.Number)
                        {
                            m_StringNums.Insert(0, ent.Number);
                            break;
                        }
                    }

                    m_CustomContent.RemoveAt(i);
                    AddHash(ent.Number);
                    if (!string.IsNullOrEmpty(ent.Args))
                    {
                        AddHash(ent.Args.GetHashCode());
                    }
                    if (m_CustomContent.Count == 0)
                    {
                        m_CustomHash = 0;
                    }
                    return(true);
                }
            }
            return(false);
        }