public static T InvokeApi <T>(string url, RequestFunction requestFun) where T : class
        {
            using (HttpClient link = new HttpClient())
            {
                HttpRequestMessage requestMessage = new HttpRequestMessage();

                switch (requestFun)
                {
                case RequestFunction.Get:
                    requestMessage.Method = HttpMethod.Get;
                    break;

                case RequestFunction.Post:
                    requestMessage.Method = HttpMethod.Post;
                    break;

                case RequestFunction.Put:
                    requestMessage.Method = HttpMethod.Put;
                    break;

                case RequestFunction.Delete:
                    requestMessage.Method = HttpMethod.Delete;
                    break;

                default:
                    requestMessage.Method = HttpMethod.Get;
                    break;
                }
                requestMessage.RequestUri = new Uri(url);
                var result  = link.SendAsync(requestMessage).Result;
                T   context = JsonConvert.DeserializeObject <T>(result.Content.ReadAsStringAsync().Result);
                return(context);
            }
        }
Esempio n. 2
0
        public IntPtr RequestFunctionPtr(RequestFunction request)
        {
            switch (request)
            {
            case RequestFunction.IsProcessValid:
                return(fnIsProcessValid);

            case RequestFunction.OpenRemoteProcess:
                return(fnOpenRemoteProcess);

            case RequestFunction.CloseRemoteProcess:
                return(fnCloseRemoteProcess);

            case RequestFunction.ReadRemoteMemory:
                return(fnReadRemoteMemory);

            case RequestFunction.WriteRemoteMemory:
                return(fnWriteRemoteMemory);

            case RequestFunction.EnumerateProcesses:
                return(fnEnumerateProcesses);

            case RequestFunction.EnumerateRemoteSectionsAndModules:
                return(fnEnumerateRemoteSectionsAndModules);

            case RequestFunction.DisassembleRemoteCode:
                return(fnDisassembleRemoteCode);

            case RequestFunction.ControlRemoteProcess:
                return(fnControlRemoteProcess);
            }

            throw new ArgumentException(nameof(request));
        }
Esempio n. 3
0
        private void RegisterMethod(RequestFunction method, MethodInfo methodInfo)
        {
            Contract.Requires(methodInfo != null);

            List <MethodInfo> infos;

            if (!methodRegistry.TryGetValue(method, out infos))
            {
                infos = new List <MethodInfo>();

                methodRegistry.Add(method, infos);
            }

            infos.Add(methodInfo);
        }
Esempio n. 4
0
 public DeferredDictionary(RequestFunction requester)
 {
     request = requester;
 }
Esempio n. 5
0
 public DeferredList(QueryableFunction requester)
 {
     request = () => requester().ToList();
 }
Esempio n. 6
0
 public DeferredList(RequestFunction requester)
 {
     request = requester;
 }
 public DeferredCollection(RequestFunction requester)
 {
     request = requester;
 }