예제 #1
0
 public JsonValue ToJson(IJsonContext context) {
     var dict = new JsonDictionary();
     dict["UserName"] = context.ToJson(UserName);
     dict["ValidTo"] = context.ToJson(ValidTo.ToUnixTime());
     dict["ApiToken"] = context.ToJson(ApiToken);
     return dict;
 }
예제 #2
0
파일: SetModel.cs 프로젝트: aata/szotar
        public JsonValue ToJson(IJsonContext context)
        {
            var dict = new JsonDictionary();

            dict.Set("id", SetID);
            dict.Set("url", Uri.ToString());
            dict.Set("title", Title);
            dict.Set("created_by", Author);
            if (Description != null)
            {
                dict.Set("description", Description);
            }
            dict.Set("term_count", TermCount);
            dict.Set("created_date", Created.ToUnixTime());
            dict.Set("modified_date", Modified.ToUnixTime());
            dict["subjects"] = context.ToJson(Subjects);
            dict.Set("visibility", Visibility.ToApiString());
            dict.Set("editable", EditPermissions.ToApiString());
            dict.Set("has_access", HasAccess);
            dict.Set("has_discussion", HasDiscussion);
            dict.Set("lang_terms", TermLanguageCode);
            dict.Set("lang_definitions", DefinitionLanguageCode);
            if (Terms != null)
            {
                dict["terms"] = context.ToJson(Terms);
            }
            return(dict);
        }
예제 #3
0
파일: Credentials.cs 프로젝트: aata/szotar
        public JsonValue ToJson(IJsonContext context)
        {
            var dict = new JsonDictionary();

            dict["UserName"] = context.ToJson(UserName);
            dict["ValidTo"]  = context.ToJson(ValidTo.ToUnixTime());
            dict["ApiToken"] = context.ToJson(ApiToken);
            return(dict);
        }
예제 #4
0
        JsonValue IJsonConvertible.ToJson(IJsonContext context)
        {
            var dict = new JsonDictionary();

            dict.Items.Add("Entries", context.ToJson(Entries));
            dict.Items.Add("MaximumSize", context.ToJson(MaximumSize));

            return(dict);
        }
예제 #5
0
 public JsonValue ToJson(IJsonContext ctx)
 {
     return(new JsonDictionary()
            .Set("items", ctx.ToJson(items))
            .Set("nextItems", ctx.ToJson(nextItems))
            .Set("failed", new JsonBool(failed))
            .Set("currentItem", ctx.ToJson(CurrentItem))
            .Set("currentIndex", new JsonNumber(CurrentIndex))
            .Set("itemCount", new JsonNumber(ItemCount))
            .Set("score", new JsonNumber(Score))
            .Set("round", new JsonNumber(Round))
            .Set("lastRoundInfo", ctx.ToJson(LastRoundInfo))
            .Set("allRounds", ctx.ToJson(AllRounds.ToList()))
            .Set("title", new JsonString(Title))
            .Set("maxItemCount", new JsonNumber(maxItemCount)));
 }
예제 #6
0
파일: SetModel.cs 프로젝트: dbremner/szotar
 public JsonValue ToJson(IJsonContext context) {
     var dict = new JsonDictionary();
     dict.Set("id", SetID);
     dict.Set("url", Uri.ToString());
     dict.Set("title", Title);
     dict.Set("created_by", Author);
     if (Description != null)
         dict.Set("description",Description);
     dict.Set("term_count", TermCount);
     dict.Set("created_date", Created.ToUnixTime());
     dict.Set("modified_date", Modified.ToUnixTime());
     dict["subjects"] = context.ToJson(Subjects);
     dict.Set("visibility", Visibility.ToApiString());
     dict.Set("editable", EditPermissions.ToApiString());
     dict.Set("has_access", HasAccess);
     dict.Set("has_discussion", HasDiscussion);
     dict.Set("lang_terms", TermLanguageCode);
     dict.Set("lang_definitions", DefinitionLanguageCode);
     if (Terms != null)
         dict["terms"] = context.ToJson(Terms);
     return dict;
 }
예제 #7
0
파일: Json.cs 프로젝트: aata/szotar
            public JsonValue ToJson(object value, IJsonContext context)
            {
                var list = value as List <T>;

                if (list == null)
                {
                    throw new JsonConvertException("Value was not a List<" + typeof(T) + ">");
                }

                var array = new JsonArray();

                foreach (var item in list)
                {
                    array.Items.Add(context.ToJson(item));
                }

                return(array);
            }
예제 #8
0
 public JsonValue ToJson(IJsonContext ctx)
 {
     return new JsonDictionary()
         .Set("items", ctx.ToJson(items))
         .Set("nextItems", ctx.ToJson(nextItems))
         .Set("failed", new JsonBool(failed))
         .Set("currentItem", ctx.ToJson(CurrentItem))
         .Set("currentIndex", new JsonNumber(CurrentIndex))
         .Set("itemCount", new JsonNumber(ItemCount))
         .Set("score", new JsonNumber(Score))
         .Set("round", new JsonNumber(Round))
         .Set("lastRoundInfo", ctx.ToJson(LastRoundInfo))
         .Set("allRounds", ctx.ToJson(AllRounds.ToList()))
         .Set("title", new JsonString(Title))
         .Set("maxItemCount", new JsonNumber(maxItemCount));
 }