예제 #1
0
        public List<clsAttribute> fromJSON(JArray JSONArray)
        {
            List<clsAttribute> results = new List<clsAttribute>();

            // loop thorugh all the JSON obects in the JSON array
            foreach (JObject JSONObject in JSONArray)
            {
                clsAttribute attribute = new clsAttribute(_db); // create new blank template
                attribute.fromJSON(JSONObject); // load template based on JSON Object
                results.Add(attribute); // add new template to results
            }
            return results;
        }
예제 #2
0
        public new bool fromJSON(JObject JSONObj)
        {
            bool result = base.fromJSON(JSONObj);
            this.save();

            // check for templateAtributes
            if (JSONObj["attributes"] != null)
            {
                JArray JSONArray = (JArray)JSONObj["attributes"];

                // convert to attribute objects
                clsAttribute attribute = new clsAttribute(_db);
                attribute.objectId = this.id;
                List<clsAttribute> attributes = attribute.fromJSON(JSONArray);

                foreach (clsAttribute a in attributes)
                {
                    a.objectId = this.id; // we will not know our template id until was save our template
                    a.save();
                }
            }

            return result;
        }