System.Xml.NameTable.Get C# (CSharp) Méthode

Get() public méthode

public Get ( char key, int start, int len ) : string
key char
start int
len int
Résultat string
        public override string Get( char[] key, int start, int len ) {
            if ( len == 0 ) {
                return string.Empty;
            }

            int hashCode = len + hashCodeRandomizer;
            hashCode += ( hashCode << 7 ) ^ key[start];   // this will throw IndexOutOfRangeException in case the start index is invalid
            int end = start+len;
            for ( int i = start + 1; i < end; i++) {
                hashCode += ( hashCode << 7 ) ^ key[i];
            }
            // mix it a bit more
            hashCode -= hashCode >> 17; 
            hashCode -= hashCode >> 11; 
            hashCode -= hashCode >> 5;
            
            for ( Entry e = entries[hashCode & mask]; e != null; e = e.next ) {
                if ( e.hashCode == hashCode && TextEquals( e.str, key, start ) ) {
                    return e.str;
                }
            }
            return null;
        }

Same methods

NameTable::Get ( string value ) : string

Usage Example

Exemple #1
0
        /// <summary>
        /// Creates a new AtomizedString object.
        /// </summary>
        /// <param name="str">The string.  May not be null.</param>
        /// <param name="nameTable">The <Typ>NameTable</Typ> that should contain <P>str</P>,
        /// although this is not enforced (see remarks.)</param>
        /// <remarks>
        /// In order for <Typ>AtomizedString</Typ> comparisons to work correctly, the <P>str</P>
        /// parameter must be contained in the <P>nameTable</P>.  For performance reasons, this
        /// is not checked at runtime, except in debug builds where it throws ArgumentException.
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// <P>str</P> or <P>nameTable</P> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// (debug build only) <P>nameTable</P> does not contain <P>str</P>.
        /// </exception>
        internal AtomizedString(string str, NameTable nameTable)
        {
            if (str == null) throw new ArgumentNullException("str");
            if (nameTable == null) throw new ArgumentNullException("nameTable");
            m_NameTable = nameTable;
            // although there is no real guarantee that str is in nameTable without
            // specifically checking, it's not worth it to do so (except in debug builds.)
#if DEBUG
            if (null == nameTable.Get(str)) throw new ArgumentException(Resources.WrongNameTable);
#endif
            m_String = str;
        }
All Usage Examples Of System.Xml.NameTable::Get