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);
        }
        internal new static ChannelObjectWithInfo FromJObject(JObject jObj)
        {
            var result = new ChannelObjectWithInfo();

            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);
        }
        internal static UpdateChannelResponse FromJObject(JObject jObj)
        {
            var result = new UpdateChannelResponse();
            var data   = JsonHelpers.FromJObject(result, jObj);
            var msgObj = data.GetData <JObject>("message");

            if (msgObj != null)
            {
                result.Message = Message.FromJObject(msgObj);
            }
            var chanObj = data.GetData <JObject>("channel");

            if (chanObj != null)
            {
                result.Channel = ChannelObjectWithInfo.FromJObject(chanObj);
            }
            return(result);
        }
Beispiel #4
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);
        }