Get() public method

public Get ( char key, int start, int len ) : string
key char
start int
len int
return string
Esempio n. 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;
        }
        public string LookupPrefix(string ns)
        {
            IXmlNamespaceResolver nsr = reader as IXmlNamespaceResolver;

            return(nsr.LookupPrefix(NameTable.Get(ns)));
        }
Esempio n. 3
0
 public override string LookupNamespace(string prefix)
 {
     return(context.NamespaceManager.LookupNamespace(
                NameTable.Get(prefix)));
 }
Esempio n. 4
0
 public string LookupPrefix(string ns)
 {
     return(context.NamespaceManager.LookupPrefix(NameTable.Get(ns)));
 }
Esempio n. 5
0
        public MFTestResults XmlTest5_NameTable()
        {
            /// <summary>
            /// Tests the NameTable class, which implements XmlNameTable
            /// </summary>
            ///
            bool testResult = true;
            try
            {
                XmlReader testReader = XmlReader.Create(new testStream());

                NameTable testNT = new NameTable();
                object root = testNT.Add("root");
                object element1 = testNT.Add("TestElement1");
                testReader.Read();
                object localName = testReader.LocalName;
                if (!(localName == root))
                {
                    Log.Comment("1st reading, expected local name '" + root + "' but got '" + localName + "'");
                    testResult = false;
                }
                testReader.Read();
                localName = testReader.LocalName;
                if (!(localName == element1))
                {
                    Log.Comment("2nd reading, expected local name '" + element1 + "' but got '" + localName + "'");
                    testResult = false;
                }

                testNT.Add("test1");

                if (testNT.Get("test1").GetType() != Type.GetType("System.String"))
                    throw new Exception("Get(string) got wrong type");

                if (testNT.Get("test1") != "test1")
                    throw new Exception("Get(string) got wrong data");

                if (testNT.Get("test1".ToCharArray(), 0, 5).GetType() != Type.GetType("System.String"))
                    throw new Exception("Get(string) got wrong type");

                if (testNT.Get("test1".ToCharArray(), 0, 5) != "test1")
                    throw new Exception("Get(string) got wrong data");

                testNT.Add("test2".ToCharArray(), 0, 5);

                if (testNT.Get("test2").GetType() != Type.GetType("System.String"))
                    throw new Exception("Get(string) got wrong type");

                if (testNT.Get("test2") != "test2")
                    throw new Exception("Get(string) got wrong data");

                if (testNT.Get("test2".ToCharArray(), 0, 5).GetType() != Type.GetType("System.String"))
                    throw new Exception("Get(string) got wrong type");

                if (testNT.Get("test2".ToCharArray(), 0, 5) != "test2")
                    throw new Exception("Get(string) got wrong data");

            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }