Example #1
0
 public static UploadObject Load(JToken json, ISite campfireSite)
 {
   return new UploadObject
   {
     ByteCount = json.Value<int>("byte_size"),
     ContentType = json.Value<string>("content_type"),
     CreatedAt = json.Value<DateTime>("created_at"),
     ID = json.Value<int>("id"),
     Name = json.Value<string>("name"),
     Room = campfireSite.GetRoom(json.Value<int>("room_id")),
     User = campfireSite.GetUser(json.Value<int>("user_id")),
     FullUrl = json.Value<string>("full_url")
   };
 }
Example #2
0
        public static Message Load(JToken json, ISite campfireSite)
        {
            int? userID = json.Value<int?>("user_id");

            User user = null;
            
            if (userID.HasValue)
                user = campfireSite.GetUser(userID.Value);

            return new Message(campfireSite)
                {
                    ID = json.Value<int>("id"),
                    Body = json.Value<string>("body"),
                    User = user,
                    Room = campfireSite.GetRoom(json.Value<int?>("room_id").GetValueOrDefault()),
                    Type = (MessageType)Enum.Parse(typeof(MessageType), json.Value<string>("type").Replace("Message", ""), true),
                    CreatedAt = json.Value<DateTime>("created_at")
                };
        }