Posts

Showing posts from June, 2016

Get OAuth 2.0 access token of Paypal using HttpClient in c#

Here called paypal Rest API using System.Net.Http.HttpClient for OAuth 2.0 access token try  { // ClientId of your Paypal app API          string  API ClientId = " ASCxaD7FzuvGbX-xxxxxxxx.....xxxxxxxxxxx-6RZDgwLuOyrCsy3 " ;                 // secret key of you Paypal app API string   API Secret = " ENldyFXuW46R7Wv0 xxxxxxxx.....xxxxxxxxxxx ee8pyH8 " ;          using ( var client = new System.Net.Http. HttpClient ())         {              var byteArray = Encoding .UTF8.GetBytes( API ClientId + ":" + API Secret );             client.DefaultRequestHeaders.Authorization = new Headers. AuthenticationHeaderValue ( "Basic" , Convert .ToBase64String(byteArray));              var url = new Uri ( "https://api.sandbox.paypal.com/v1/oauth2/token" , UriKind .Absolute);             client.DefaultRequestHeaders.IfModifiedSince = DateTime .UtcNow;              var requestParams = new List < KeyValuePai

Generics method using interface in c#

Implement an Interface with Generic Methods namespace  Win.Data { // Created Interface for field of table      public   interface   IFieldTable     {          string  Id {  get ;  set ; }          DateTime  TimeStamp {  get ;  set ; }          string  User {  get ;  set ; }          string  View {  get ;  set ; }          string  Name {  get ;  set ; }          //string QData { get; set; }     } // FieldString class inhirated from IFieldTable      public   class   FieldString  :  IFieldTable     {          public   string  Id {  get ;  set ; }          public   DateTime  TimeStamp {  get ;  set ; }          public   string  User {  get ;  set ; }          public   string  View {  get ;  set ; }          public   string  Name {  get ;  set ; }          public   string  Data {  get ;  set ; }     } // FieldInt class inhirated from IFieldTable      public   class   FieldInt  :  IFieldTable     {          public   string  Id {  get ;  set ; }          public