예제 #1
0
        private void ReadSpecialTest(XElement e)
        {
            if (SpecialTest == null)
            {
                SpecialTest = new Dictionary <string, string>();
            }
            var key = e.Attribute("key");

            if (key != null)
            {
                SpecialTest.Add(key.Value, e.Value);
            }
        }
        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);

            if (x.Root == null)
            {
                return;
            }


            var eqset   = 0;
            var menuset = 0;

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                case "FundItem":
                    if (FundItem == null)
                    {
                        FundItem = new Dictionary <int, decimal?>();
                    }
                    var fu = e.Attribute("fund");
                    if (fu != null)
                    {
                        FundItem.Add(fu.Value.ToInt(), e.Value.ToDecimal());
                    }
                    break;

                case "FamilyAttend":
                    var fa = new FamilyAttendInfo();
                    fa.PeopleId  = GetAttr(e, "PeopleId").ToInt2();
                    fa.Attend    = GetAttr(e, "Attend").ToBool();
                    fa.Name      = GetAttr(e, "Name");
                    fa.Birthday  = GetAttr(e, "Birthday");
                    fa.Email     = GetAttr(e, "Email");
                    fa.MaritalId = GetAttr(e, "MaritalId").ToInt2();
                    fa.GenderId  = GetAttr(e, "GenderId").ToInt2();
                    if (FamilyAttend == null)
                    {
                        FamilyAttend = new List <FamilyAttendInfo>();
                    }
                    FamilyAttend.Add(fa);
                    break;

                case "ExtraQuestion":
                    if (ExtraQuestion == null)
                    {
                        ExtraQuestion = new List <Dictionary <string, string> >();
                    }
                    var eqsetattr = e.Attribute("set");
                    if (eqsetattr != null)
                    {
                        eqset = eqsetattr.Value.ToInt();
                    }
                    if (ExtraQuestion.Count == eqset)
                    {
                        ExtraQuestion.Add(new Dictionary <string, string>());
                    }
                    var eq = e.Attribute("question");
                    if (eq != null)
                    {
                        ExtraQuestion[eqset].Add(eq.Value, e.Value);
                    }
                    break;

                case "Text":
                    if (Text == null)
                    {
                        Text = new List <Dictionary <string, string> >();
                    }
                    var txsetattr = e.Attribute("set");
                    if (txsetattr != null)
                    {
                        eqset = txsetattr.Value.ToInt();
                    }
                    if (Text.Count == eqset)
                    {
                        Text.Add(new Dictionary <string, string>());
                    }
                    var tx = e.Attribute("question");
                    if (tx != null)
                    {
                        Text[eqset].Add(tx.Value, e.Value);
                    }
                    break;

                case "YesNoQuestion":
                    if (YesNoQuestion == null)
                    {
                        YesNoQuestion = new Dictionary <string, bool?>();
                    }
                    var ynq = e.Attribute("question");
                    if (ynq != null)
                    {
                        YesNoQuestion.Add(ynq.Value, e.Value.ToBool());
                    }
                    break;

                case "option":
                    if (option == null)
                    {
                        option = new List <string>();
                    }
                    option.Add(e.Value);
                    break;

                case "Checkbox":
                    if (Checkbox == null)
                    {
                        Checkbox = new List <string>();
                    }
                    Checkbox.Add(e.Value);
                    break;

                case "MenuItem":
                    if (MenuItem == null)
                    {
                        MenuItem = new List <Dictionary <string, int?> >();
                    }
                    var menusetattr = e.Attribute("set");
                    if (menusetattr != null)
                    {
                        menuset = menusetattr.Value.ToInt();
                    }
                    while (MenuItem.Count - 1 < menuset)
                    {
                        MenuItem.Add(new Dictionary <string, int?>());
                    }
                    var aname  = e.Attribute("name");
                    var number = e.Attribute("number");
                    if (aname != null && number != null)
                    {
                        MenuItem[menuset].Add(aname.Value, number.Value.ToInt());
                    }
                    break;

                case "MissionTripGoerId":
                    MissionTripGoerId = e.Value.ToInt();
                    break;

                case "CreatingAccount":
                    CreatingAccount = e.Value.ToBool();
                    break;

                case "SpecialTest":
                    if (SpecialTest == null)
                    {
                        SpecialTest = new Dictionary <string, string>();
                    }
                    var key = e.Attribute("key");
                    if (key != null)
                    {
                        SpecialTest.Add(key.Value, e.Value);
                    }
                    break;

                default:
                    Util.SetPropertyFromText(this, TranslateName(name), e.Value);
                    break;
                }
            }
        }