Exemple #1
0
        /// <summary>
        /// 상세 옵션정보 예외처리 룰 채움
        /// </summary>
        /// <param name="data">Json데이타</param>
        /// <returns></returns>
        private ValidationRules CreateValidationRules(JSONObject data)
        {
            //상세 옵션의 FreeText 옵션 정보를 채우기
            ValidationRules ValidationRules = new GEP.Data.ValidationRules();
            if (data.Dictionary.Keys.Contains("MinValues"))
            {
                ValidationRules.MinValues = Convert.ToInt32(data.Dictionary["MinValues"].String);
            }
            if (data.Dictionary.Keys.Contains("MaxValues"))
            {
                ValidationRules.MaxValues = Convert.ToInt32(data.Dictionary["MaxValues"].String);
            }
            if (data.Dictionary.Keys.Contains("SelectionMode"))
            {
                ValidationRules.SelectionMode = data.Dictionary["SelectionMode"].String;
            }
            if (data.Dictionary.Keys.Contains("VariationSpecifics"))
            {
                ValidationRules.VariationSpecifics = data.Dictionary["VariationSpecifics"].String;
            }
            if (data.Dictionary.Keys.Contains("Relationship"))
            {
                var Temp = data.Dictionary["Relationship"];
                Relationship relationship = new Relationship();
                if (Temp.Dictionary != null)
                {
                    if (Temp.Dictionary.Keys.Contains("ParentName"))
                    {
                        relationship.ParentName = Temp.Dictionary["ParentName"].String;
                    }

                    if (Temp.Dictionary.Keys.Contains("ParentValue"))
                    {
                        relationship.ParentValue = Temp.Dictionary["ParentValue"].String;
                    }
                }
                ValidationRules.Relationship = relationship;
            }

            return ValidationRules;
        }
Exemple #2
0
 private static void RecursiveDictionaryToString(JSONObject obj,
     StringBuilder sb, int level)
 {
     foreach (KeyValuePair<string, JSONObject> kvp in obj.Dictionary)
     {
         sb.Append(' ', level * 2);
         sb.Append(kvp.Key);
         sb.Append(" => ");
         RecursiveObjectToString(kvp.Value, sb, level);
         sb.AppendLine();
     }
 }
Exemple #3
0
 private static void RecursiveObjectToString(JSONObject obj,
     StringBuilder sb, int level)
 {
     if (obj.IsDictionary)
     {
         sb.AppendLine();
         RecursiveDictionaryToString(obj, sb, level + 1);
     }
     else if (obj.IsArray)
     {
         foreach (JSONObject o in obj.Array)
         {
             RecursiveObjectToString(o, sb, level);
             sb.AppendLine();
         }
     }
     else // some sort of scalar value
     {
         sb.Append(obj.String);
     }
 }
Exemple #4
0
        /// <summary>
        /// Recursively constructs this JSONObject 
        /// </summary>
        private static JSONObject Create(object o)
        {
            JSONObject obj = new JSONObject();
            if (o is object[])
            {
                object[] objArray = o as object[];
                obj._arrayData = new JSONObject[objArray.Length];
                for (int i = 0; i < obj._arrayData.Length; ++i)
                {
                    obj._arrayData[i] = Create(objArray[i]);
                }
            }
            else if (o is Dictionary<string, object>)
            {
                obj._dictData = new Dictionary<string, JSONObject>();
                Dictionary<string, object> dict =
                    o as Dictionary<string, object>;
                foreach (string key in dict.Keys)
                {
                    obj._dictData[key] = Create(dict[key]);
                }
            }
            else if (o != null) // o is a scalar
            {
                obj._stringData = o.ToString();
            }

            return obj;
        }