コード例 #1
0
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
        public Channel[] GetAllChannels(string search = "")
        {
            Cursor <Channel> cursor = new Cursor <Channel>();
            string           page   = "1";

            do
            {
                if (!string.IsNullOrEmpty(cursor.Next))
                {
                    page = ExtractQueryString(cursor.Next)["page"];
                }

                using (var request = new Users.Base()
                {
                    DefaultHeaders = new WebHeaderCollection()
                    {
                        { HttpRequestHeader.Accept, "application/json" },
                        { HttpRequestHeader.ContentType, "application/json" },
                        { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                    }
                }.GET(new Dictionary <string, string>()
                {
                    { "search", search },
                    { "page", page }
                })) {
                    cursor.AddRange((Channel[])Parser.JSONtoEntity(request.Payload, typeof(Channel[])));
                    cursor.Next     = request.Payload.next.ToString();
                    cursor.Previous = request.Payload.previous.ToString();
                }
            } while (!string.IsNullOrEmpty(cursor.Next));
            return(cursor.ToArray());
        }
コード例 #2
0
        static void PopulateDemoDatabase(iSerializerSession sess)
        {
            Person[] personsTest = new Person[]
            {
                new Person(Person.eSex.Female, "Jenifer Smith", new string[0]),
                new Person(Person.eSex.Male, "Konstantin", new string[] { "+7 926 139 63 18" }),
                new Person(Person.eSex.Male, "John Smith", new string[] { "+1 800 123 4567", "+1 800 123 4568" }),
                new Person(Person.eSex.Female, "Mary Jane", new string[] { "555-1212" }),
                new Person(Person.eSex.Other, "Microsoft", new string[] { "+1 800 642 7676", "1-800-892-5234" }),
            };

            Cursor <Person> curPerson = sess.Cursor <Person>();

            using (var trans = sess.BeginTransaction())
            {
                curPerson.AddRange(personsTest);
                trans.Commit();
            }
        }
コード例 #3
0
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
        public Entities.Friendship[] GetAllFriendships()
        {
            Cursor <Entities.Friendship> cursor = new Cursor <Entities.Friendship>();

            do
            {
                using (var request = new Friendship.Base()
                {
                    DefaultHeaders = new WebHeaderCollection()
                    {
                        { HttpRequestHeader.Accept, "application/json" },
                        { HttpRequestHeader.ContentType, "application/json" },
                        { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                    }
                }.GET(!string.IsNullOrEmpty(cursor.Next) ? ExtractQueryString(cursor.Next) : null)) {
                    cursor.AddRange((Entities.Friendship[])Parser.JSONtoEntity(request.Payload, typeof(Entities.Friendship[])));
                    cursor.Next     = request.Payload.next.ToString();
                    cursor.Previous = request.Payload.previous.ToString();
                }
            } while (!string.IsNullOrEmpty(cursor.Next));
            return(cursor.ToArray());
        }
コード例 #4
0
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
        public Message[] GetAllMessages(int channelId)
        {
            Cursor <Message> cursor = new Cursor <Message>();

            do
            {
                using (var request = new Messaging.Channel.Message.Base(channelId)
                {
                    DefaultHeaders = new WebHeaderCollection()
                    {
                        { HttpRequestHeader.Accept, "application/json" },
                        { HttpRequestHeader.ContentType, "application/json" },
                        { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                    }
                }.GET(!string.IsNullOrEmpty(cursor.Next) ? ExtractQueryString(cursor.Next) : null)) {
                    cursor.AddRange((Message[])Parser.JSONtoEntity(request.Payload, typeof(Message[])));
                    cursor.Next     = request.Payload.next.ToString();
                    cursor.Previous = request.Payload.previous.ToString();
                }
            } while (!string.IsNullOrEmpty(cursor.Next));
            return(cursor.ToArray());
        }
コード例 #5
0
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
        public Cursor <Entities.Friendship> GetFriendships(string page = "1")
        {
            Cursor <Entities.Friendship> cursor = new Cursor <Entities.Friendship>();

            using (var request = new Friendship.Base()
            {
                DefaultHeaders = new WebHeaderCollection()
                {
                    { HttpRequestHeader.Accept, "application/json" },
                    { HttpRequestHeader.ContentType, "application/json" },
                    { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                }
            }.GET(page != null ? new Dictionary <string, string>()
            {
                { "page", page }
            } : null)) {
                cursor.AddRange((Entities.Friendship[])Parser.JSONtoEntity(request.Payload, typeof(Entities.Friendship[])));
                cursor.Next     = request.Payload.next.ToString();
                cursor.Previous = request.Payload.previous.ToString();

                return(cursor);
            }
        }
コード例 #6
0
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
        public Cursor <Message> GetMessages(int channelId, string page = "1")
        {
            Cursor <Message> cursor = new Cursor <Message>();

            using (var request = new Messaging.Channel.Message.Base(channelId)
            {
                DefaultHeaders = new WebHeaderCollection()
                {
                    { HttpRequestHeader.Accept, "application/json" },
                    { HttpRequestHeader.ContentType, "application/json" },
                    { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                }
            }.GET(page != null ? new Dictionary <string, string>()
            {
                { "page", page }
            } : null)) {
                cursor.AddRange((Message[])Parser.JSONtoEntity(request.Payload, typeof(Message[])));
                cursor.Next     = request.Payload.next.ToString();
                cursor.Previous = request.Payload.previous.ToString();

                return(cursor);
            }
        }
コード例 #7
0
ファイル: Session.cs プロジェクト: mehdi-payday/spherechat
        public Cursor <Channel> GetChannels(string search = "", string page = "1")
        {
            Cursor <Channel> cursor = new Cursor <Channel>();

            using (var request = new Messaging.Channel.Base()
            {
                DefaultHeaders = new WebHeaderCollection()
                {
                    { HttpRequestHeader.Accept, "application/json" },
                    { HttpRequestHeader.ContentType, "application/json" },
                    { HttpRequestHeader.Authorization, "Token " + Auth.Token }
                }
            }.GET(new Dictionary <string, string>()
            {
                { "search", search },
                { "page", page }
            })) {
                cursor.AddRange((Channel[])Parser.JSONtoEntity(request.Payload, typeof(Channel[])));
                cursor.Next     = request.Payload.next.ToString();
                cursor.Previous = request.Payload.previous.ToString();

                return(cursor);
            }
        }