コード例 #1
0
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Constructor loads properties from an XML string
        /// </summary>
        /// <param name="XML">XML string with property values</param>
        // -------------------------------------------------------------------------------------
        public QuestionListItems(string XML)
            : base()
        {
            try
              {
            m_Width = ControlWidth;
            m_Rows = Rows;

            if (XML == string.Empty)
              return;

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(XML);

            if (doc.DocumentElement == null)
              return;
            if (doc.DocumentElement.Name != LIST_ROOT)
              throw new InvalidParameterException("Invalid root element: " + XML);

            if (doc.DocumentElement.SelectSingleNode("./" + ORDER) != null)
            {
              m_ItemOrder = (ListItemOrder) Enum.Parse(typeof (ListItemOrder),
                                                   doc.DocumentElement.SelectSingleNode("./" + ORDER).InnerXml);
            }

            if (doc.DocumentElement.SelectSingleNode("./" + WIDTH) != null)
            {
              m_Width = Convert.ToInt32(doc.DocumentElement.SelectSingleNode("./" + WIDTH).InnerXml);
            }

            if (doc.DocumentElement.SelectSingleNode("./" + ROWS) != null)
            {
              m_Rows = Convert.ToInt32(doc.DocumentElement.SelectSingleNode("./" + ROWS).InnerXml);
            }

            if (doc.DocumentElement.SelectSingleNode("./" + ITEMS) != null)
            {
              XmlNode listNode = doc.DocumentElement.SelectSingleNode("./" + ITEMS);
              foreach (XmlNode QuestionListItemNode in listNode.ChildNodes)
              {
            QuestionListItem questionListItem = new QuestionListItem(QuestionListItemNode);
            Add(questionListItem);
              }
            }
              }
              catch (Exception e)
              {
            if (e is InvalidParameterException)
              throw e;
            else
            {
              InvalidParameterException invalidParameterException =
            new InvalidParameterException(XML);
              throw invalidParameterException;
            }
              }
        }
コード例 #2
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Parses the input XML and set class properties
 /// </summary>
 /// <param name="XML">XML string wich contains class properties</param>
 // -------------------------------------------------------------------------------------
 private void ParseQuestionConstraint(string XML)
 {
     if (XML == string.Empty)
     return;
       try
       {
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(XML);
     ParseQuestionConstraint(doc);
     m_XML = XML;
       }
       catch (Exception e)
       {
     InvalidParameterException invalidParameterException =
       new InvalidParameterException(e.Message);
     throw invalidParameterException;
       }
 }