Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var match = new Match
            {
                ID = 69
            };
            //BridgeTest();

            var request = new CustomCalculationServiceRequest
            {
                MethodType = CustomCalculationServiceRequest.RequestTypeEnum.POST,
                MethodController = "Calculation",
                Key = "raktelis",
                MethodName = "CalculateStatistics",
                Body = new Match() { ID = 69, Duration = 123456789 },
            };


            var connection = new CustomCalculationServiceConnection();
            var mt = JsonConvert.SerializeObject(new Match(){ID = 5});
            var re = JsonConvert.DeserializeObject(mt);
            var re2 = JsonConvert.DeserializeObject<Match>(mt);
            var c = connection.Request(request);

            Console.WriteLine("GREAT success!");
            Console.ReadKey();
        }
Exemplo n.º 2
0
 public Information GetWorstAgainst(IEnumerable<Match> matches)
 {
     var request = new CustomCalculationServiceRequest
     {
         MethodType = CustomCalculationServiceRequest.RequestTypeEnum.POST,
         MethodController = "Calculation",
         Key = Key,
         MethodName = "Worst",
         Body = matches,
     };
     return _connectioToApi.Request<Information>(request);
 }
Exemplo n.º 3
0
 public Match GetMatchStatistics(Match match)
 {
     var request = new CustomCalculationServiceRequest
     {
         MethodType = CustomCalculationServiceRequest.RequestTypeEnum.POST,
         MethodController = "Calculation",
         Key = Key,
         MethodName = "Statistics",
         Body = match,
     };
     return _connectioToApi.Request<Match>(request);
 }
Exemplo n.º 4
0
 public PlayerRating GetPlayerRating(IEnumerable<Match> matches, int playerId)
 {
     var request = new CustomCalculationServiceRequest
     {
         MethodType = CustomCalculationServiceRequest.RequestTypeEnum.POST,
         MethodController = "Calculation",
         Key = Key,
         MethodName = "Rating",
         Body = matches,
     };
     request.AddParamater("PlayerID", playerId.ToString());
     return _connectioToApi.Request<PlayerRating>(request);
 }
Exemplo n.º 5
0
 public Match CalculateMatchDetails(Match match)
 {
     var request = new CustomCalculationServiceRequest
     {
         MethodName = "MyMethod",
         MethodController = "Calculation",
         Body = match,
         URLParameters = new[] { "2" },
         MethodType = CustomCalculationServiceRequest.RequestTypeEnum.POST
     };
     CustomCalculationServiceConnection a = new CustomCalculationServiceConnection();
     object response = a.Request(request);
     return null;
 }
Exemplo n.º 6
0
 private static void RequestTest()
 {
     CustomCalculationServiceRequest test = new CustomCalculationServiceRequest
     {
         MethodController = "Calculation",
         Key = "raktelis",
         MethodName = "CalculateStatistics"
     };
     test.AddParamater("vardas", "vardenis");
     test.AddParamater("amzius", "99");
     test.AddParamater("pavarde", "pavardenis");
     Console.WriteLine("url: {0}", test.ToRequestString());
     test.ToRequestString();
 }
Exemplo n.º 7
0
 public WinrateItem GetWinrate(IEnumerable<Match> matches, int playerId, int? enemyHeroId)
 {
     var request = new CustomCalculationServiceRequest
     {
         MethodType = CustomCalculationServiceRequest.RequestTypeEnum.POST,
         MethodController = "Calculation",
         Key = Key,
         MethodName = "Winrate",
         Body = matches,
     };
     request.AddParamater("PlayerID", playerId.ToString());
     if (enemyHeroId!=null)
         request.AddParamater("enemyHeroId", enemyHeroId.ToString());
     return _connectioToApi.Request<WinrateItem>(request);
 }
        public T Request <T>(CustomCalculationServiceRequest request)
        {
            using (var client = new JsonServiceClient())
            {
                switch (request.MethodType)
                {
                case CustomCalculationServiceRequest.RequestTypeEnum.POST:
                    var json = JsonConvert.SerializeObject(request.Body);
                    return(client.Post <T>(request.ToRequestString(), json));

                case CustomCalculationServiceRequest.RequestTypeEnum.GET:
                    return(client.Get <T>(request.ToRequestString()));

                default:
                    throw new NotImplementedException("Šitas metodas neimplementuotas: " + request.MethodType);
                }
            }
        }