Esempio n. 1
0
        public override void ReadJson(JObject obj)
        {
            base.ReadJson(obj);
            if (obj["Name"] != null && ((JValue)obj["Name"]).Value != null)
            {
                Name = ((JValue)obj["Name"]).Value.ToString();
            }
            if (obj["Description"] != null && ((JValue)obj["Description"]).Value != null)
            {
                Description = ((JValue)obj["Description"]).Value.ToString();
            }
            if (obj["QuestionaireKey"] != null && ((JValue)obj["QuestionaireKey"]).Value != null)
            {
                QuestionaireKey = ((JValue)obj["QuestionaireKey"]).Value.ToString();
            }
            if (obj["Deleted"] != null && ((JValue)obj["Deleted"]).Value != null)
            {
                Deleted = bool.Parse(((JValue)obj["Deleted"]).Value.ToString());
            }

            if (obj["SubSections"] != null)
            {
                JArray subSectionsObjs = JArray.FromObject(obj["SubSections"]);
                if (subSectionsObjs != null)
                {
                    this.SubSections.Clear();
                    foreach (JObject cobj in subSectionsObjs)
                    {
                        SubSection subSection = SubSections.Add();
                        subSection.ReadJson(cobj);
                    }
                }
            }

            if (obj["Questions"] != null)
            {
                JArray questionsObjs = JArray.FromObject(obj["Questions"]);
                if (questionsObjs != null)
                {
                    this.Questions.Clear();
                    foreach (JObject cobj in questionsObjs)
                    {
                        QuestionTypes questionType = QuestionTypes.None;
                        if (cobj["QuestionType"] != null && ((JValue)cobj["QuestionType"]).Value != null)
                        {
                            questionType = (QuestionTypes)Enum.Parse(typeof(QuestionTypes), ((JValue)cobj["QuestionType"]).Value.ToString());
                        }
                        Question question = Questions.Add(questionType);
                        if (question != null)
                        {
                            question.ReadJson(cobj);
                        }
                    }
                }
            }

            ObjectState = ObjectStates.None;
            SetOriginal();
        }
Esempio n. 2
0
 public Section(DCAnalyticsObject parent) : base(parent)
 {
     Questions   = new Questions(this);
     SubSections = new SubSections(this);
     //Conditions = new SkipConditions(this);
 }