Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes and returns a new instance of the <see cref="T:QuotationMarksList"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static QuotationMarksList NewList()
        {
            QuotationMarksList list = new QuotationMarksList();

            list.EnsureLevelExists(2);
            return(list);
        }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Finds the first level that is followed by a non empty level.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public int FindGap()
        {
            QuotationMarksList tmpList = TrimmedList;

            for (int i = 0; i < tmpList.Levels; i++)
            {
                if (i < tmpList.Levels - 1 && tmpList[i].IsEmpty && !tmpList[i + 1].IsEmpty)
                {
                    return(i + 1);
                }
            }

            return(0);
        }
Exemple #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a QuotationMarksList from the specified XML string.
        /// </summary>
        /// <param name="xmlSrc">The XML source string to load.</param>
        /// <param name="wsName">Name of the writing system (used for error reporting).</param>
        /// ------------------------------------------------------------------------------------
        public static QuotationMarksList Load(string xmlSrc, string wsName)
        {
            Exception          e;
            QuotationMarksList list =
                XmlSerializationHelper.DeserializeFromString <QuotationMarksList>(xmlSrc, out e);

            if (e != null)
            {
                throw new ContinuableErrorException("Invalid QuotationMarks field while loading the " +
                                                    wsName + " writing system.", e);
            }

            return(list == null || list.Levels == 0 ? NewList() : list);
        }
Exemple #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns a copy of the list.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public QuotationMarksList Copy()
        {
            QuotationMarksList newList = new QuotationMarksList();

            for (int i = 0; i < Levels; i++)
            {
                QuotationMarks qm = new QuotationMarks();
                qm.Opening = this[i].Opening;
                qm.Closing = this[i].Closing;
                newList.Add(qm);
            }

            newList.ContinuationMark     = ContinuationMark;
            newList.ContinuationType     = ContinuationType;
            newList.LocaleOfLangUsedFrom = LocaleOfLangUsedFrom;
            return(newList);
        }
Exemple #5
0
        public void TestTrimmedList()
        {
            m_qmList.AddLevel();
            Assert.AreEqual(3, m_qmList.Levels);

            m_qmList[0].Opening = "[";
            m_qmList[0].Closing = "]";
            Assert.AreEqual(1, m_qmList.TrimmedList.Levels);

            m_qmList[1].Opening = string.Empty;
            m_qmList[1].Closing = "}";
            Assert.AreEqual(2, m_qmList.TrimmedList.Levels);

            QuotationMarksList qmTrimmed = m_qmList.TrimmedList;

            Assert.AreEqual(m_qmList[0].Opening, qmTrimmed[0].Opening);
            Assert.AreEqual(m_qmList[0].Closing, qmTrimmed[0].Closing);
            Assert.AreEqual(m_qmList[1].Opening, qmTrimmed[1].Opening);
            Assert.AreEqual(m_qmList[1].Closing, qmTrimmed[1].Closing);
        }
Exemple #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets a value indicating whether or not the list is equal to the specified list.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool Equals(QuotationMarksList list, bool considerParaCont)
        {
            if (list == null || Levels != list.Levels)
            {
                return(false);
            }

            if (considerParaCont && (ContinuationType != list.ContinuationType ||
                                     ContinuationMark != list.ContinuationMark))
            {
                return(false);
            }

            for (int i = 0; i < Levels; i++)
            {
                if (!this[i].Equals(list[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #7
0
 public void Setup()
 {
     m_qmList = QuotationMarksList.NewList();
 }