예제 #1
0
        internal static ChannelObject FromJObject(JObject jObj)
        {
            var result = new ChannelObject();

            result._data = JsonHelpers.FromJObject(result, jObj);

            var mbrs = result._data.GetData <JArray>("members");

            if (mbrs != null)
            {
                var members = new List <ChannelMember>();
                foreach (var mbr in mbrs)
                {
                    var memberObj = mbr as JObject;
                    members.Add(ChannelMember.FromJObject(memberObj));
                }
                result.Members = members;
                result._data.RemoveData("members");
            }

            var userObj = result._data.GetData <JObject>("created_by");

            if (userObj != null)
            {
                result.CreatedBy = User.FromJObject(userObj);
                result._data.RemoveData("created_by");
            }

            return(result);
        }
예제 #2
0
        internal static PartialUpdateChannelResponse FromJObject(JObject jObj)
        {
            var result = new PartialUpdateChannelResponse();
            var data   = JsonHelpers.FromJObject(result, jObj);

            var chanObj = data.GetData <JObject>("channel");

            if (chanObj != null)
            {
                result.Channel = ChannelObjectWithInfo.FromJObject(chanObj);
            }

            var mbrs = data.GetData <JArray>("members");

            if (mbrs != null)
            {
                var members = new List <ChannelMember>();
                foreach (var mbr in mbrs)
                {
                    var memberObj = mbr as JObject;
                    members.Add(ChannelMember.FromJObject(memberObj));
                }
                result.Members = members;
            }

            return(result);
        }
예제 #3
0
        internal static ChannelMember FromJObject(JObject jObj)
        {
            var result  = new ChannelMember();
            var data    = JsonHelpers.FromJObject(result, jObj);
            var userObj = data.GetData <JObject>("user");

            if (userObj != null)
            {
                result.User = User.FromJObject(userObj);
            }

            return(result);
        }
예제 #4
0
        public static Event FromJObject(JObject jObj)
        {
            var result = new Event();

            result._data = JsonHelpers.FromJObject(result, jObj);

            var msgObj = result._data.GetData <JObject>("message");

            if (msgObj != null)
            {
                result.Message = Message.FromJObject(msgObj);
                result._data.RemoveData("message");
            }
            var reactionObj = result._data.GetData <JObject>("reaction");

            if (reactionObj != null)
            {
                result.Reaction = Reaction.FromJObject(reactionObj);
                result._data.RemoveData("reaction");
            }
            var chanObj = result._data.GetData <JObject>("channel");

            if (chanObj != null)
            {
                result.Channel = ChannelObject.FromJObject(chanObj);
                result._data.RemoveData("channel");
            }
            var memberObj = result._data.GetData <JObject>("member");

            if (memberObj != null)
            {
                result.Member = ChannelMember.FromJObject(memberObj);
                result._data.RemoveData("member");
            }
            var userObj = result._data.GetData <JObject>("user");

            if (userObj != null)
            {
                result.User = User.FromJObject(userObj);
                result._data.RemoveData("user");
            }
            userObj = result._data.GetData <JObject>("me");
            if (userObj != null)
            {
                result.OwnUser = User.FromJObject(userObj);
                result._data.RemoveData("me");
            }

            return(result);
        }
예제 #5
0
        internal static ChannelState FromJObject(JObject jObj)
        {
            var result = new ChannelState();
            var data   = JsonHelpers.FromJObject(result, jObj);

            var chanObj = data.GetData <JObject>("channel");

            if (chanObj != null)
            {
                result.Channel = ChannelObjectWithInfo.FromJObject(chanObj);
            }

            var msgs = data.GetData <JArray>("messages");

            if (msgs != null)
            {
                var messages = new List <Message>();
                foreach (var msg in msgs)
                {
                    var msgObj = msg as JObject;
                    messages.Add(Message.FromJObject(msgObj));
                }
                result.Messages = messages;
            }

            var usrs = data.GetData <JArray>("watchers");

            if (usrs != null)
            {
                var users = new List <User>();
                foreach (var usr in usrs)
                {
                    var usrObj = usr as JObject;
                    users.Add(User.FromJObject(usrObj));
                }
                result.Watchers = users;
            }

            var reads = data.GetData <JArray>("read");

            if (reads != null)
            {
                var readsList = new List <Read>();
                foreach (var read in reads)
                {
                    var readObj = read as JObject;
                    readsList.Add(Read.FromJObject(readObj));
                }
                result.Reads = readsList;
            }

            var mbrs = data.GetData <JArray>("members");

            if (mbrs != null)
            {
                var members = new List <ChannelMember>();
                foreach (var mbr in mbrs)
                {
                    var memberObj = mbr as JObject;
                    members.Add(ChannelMember.FromJObject(memberObj));
                }
                result.Members = members;
            }

            return(result);
        }