Пример #1
0
        private static Work jsonToWork(JsonObject jsonObj)
        {
            Work w = new Work()
            {
                Id        = jsonObj.GetNamedString("Id"),
                Title     = jsonObj.GetNamedString("Title"),
                BeginDate = DateTime.Parse(jsonObj.GetNamedString("BeginTime")),
                EndDate   = DateTime.Parse(jsonObj.GetNamedString("EndTime")),
                Content   = jsonObj.GetNamedValue("Content").ValueType == JsonValueType.Null ?
                            null : jsonObj.GetNamedString("Content"),
                Status     = (Work.WorkStatus)(int) jsonObj.GetNamedNumber("Status"),
                Attachment = null,
            };

            if (jsonObj.GetNamedValue("Attachment").ValueType != JsonValueType.Null)
            {
                WorkFile wf = new WorkFile()
                {
                    Name = jsonObj.GetNamedObject("Attachment").GetNamedString("Name"),
                    Url  = jsonObj.GetNamedObject("Attachment").GetNamedString("Url"),
                };
                w.Attachment = wf;
            }
            return(w);
        }
Пример #2
0
        private static IJsonValue workFileToJson(WorkFile wf)
        {
            JsonObject jsonObj = new JsonObject();

            jsonObj["Name"] = JsonValue.CreateStringValue(wf.Name);
            jsonObj["Url"]  = JsonValue.CreateStringValue(wf.Url);
            return(jsonObj);
        }