Пример #1
0
        private void ApproveRequest(IAsyncResult ar)
        {
            HttpWebRequest request = (HttpWebRequest)ar.AsyncState;
            Stream         stream  = request.EndGetRequestStream(ar);

            Reddit.WritePostBody(stream, new
            {
                id = FullName,
                uh = Reddit.User.Modhash
            });
            request.BeginGetResponse(new AsyncCallback(ApproveResponse), request);
        }
Пример #2
0
        private void CommentRequest(IAsyncResult ar)
        {
            StateObject    postState = (StateObject)ar.AsyncState;
            HttpWebRequest request   = postState.Request;
            Stream         stream    = request.EndGetRequestStream(ar);

            Reddit.WritePostBody(stream, new
            {
                text     = (String)postState.ParameterValue,
                thing_id = FullName,
                uh       = Reddit.User.Modhash
            });
        }
Пример #3
0
        private void ReplyRequest(IAsyncResult ar)
        {
            CommentState   commentState = (CommentState)ar.AsyncState;
            HttpWebRequest request      = commentState.AsyncRequest;
            Stream         stream       = request.EndGetRequestStream(ar);

            Reddit.WritePostBody(stream, new
            {
                text     = (String)commentState.ParameterValue,
                thing_id = FullName,
                uh       = Reddit.User.Modhash,
                api_type = "json"
                           //r = Subreddit
            });
        }
Пример #4
0
        private void EditTextRequest(IAsyncResult ar)
        {
            CommentState   commentState = (CommentState)ar.AsyncState;
            HttpWebRequest request      = commentState.AsyncRequest;
            Stream         stream       = request.EndGetRequestStream(ar);

            Reddit.WritePostBody(stream, new
            {
                api_type = "json",
                text     = (String)commentState.ParameterValue,
                thing_id = FullName,
                uh       = Reddit.User.Modhash
            });

            request.BeginGetResponse(new AsyncCallback(EditTextResponse), commentState);
        }
Пример #5
0
        private void DistinguishRequest(IAsyncResult ar)
        {
            CommentState    commentState    = (CommentState)ar.AsyncState;
            DistinguishType distinguishType = (DistinguishType)commentState.ParameterValue;
            HttpWebRequest  request         = commentState.AsyncRequest;
            Stream          stream          = request.EndGetRequestStream(ar);

            string how;

            switch (distinguishType)
            {
            case DistinguishType.Admin:
                how = "admin";
                break;

            case DistinguishType.Moderator:
                how = "yes";
                break;

            case DistinguishType.None:
                how = "no";
                break;

            default:
                how = "special";
                break;
            }

            Reddit.WritePostBody(stream, new
            {
                how,
                id = Id,
                uh = Reddit.User.Modhash
            });

            request.BeginGetResponse(new AsyncCallback(DistinguishResponse), commentState);
        }