protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            System.Net.ServicePointManager.ServerCertificateValidationCallback +=
                delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                         System.Security.Cryptography.X509Certificates.X509Chain chain,
                         System.Net.Security.SslPolicyErrors sslPolicyErrors)
            {
                return(true);           // **** Always accept
            };
            ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;


            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += delegate {
                button.Text = string.Format("{0} calls!", count++);

                // Configure API key authorization: key
                if (!Configuration.Default.ApiKey.ContainsKey("apikey"))
                {
                    Configuration.Default.ApiKey.Add("apikey", "YOUR_API_KEY");
                }
                // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
                // Configuration.Default.ApiKeyPrefix.Add("apikey", "Bearer");

                var apiInstance = new AlbumApi();
                var albumId     = "14250417";         // string | The musiXmatch album id
                var format      = "json";             // string | output format: json, jsonp, xml. (optional)  (default to json)

                try
                {
                    //
                    InlineResponse200 result = apiInstance.AlbumGetGet(albumId, format);
                    var res = JsonConvert.SerializeObject(result);
                    Log.Debug("SWAGGER", res);
                }
                catch (IO.Swagger.Client.ApiException e)
                {
                    Log.Warn("SWAGGER", "Exception when calling DefaultApi.AlbumGetGet: " + e.Message);
                }
                catch (Exception e)
                {
                    Log.Warn("SWAGGER", "Exception when calling DefaultApi.AlbumGetGet: " + e.Message);
                }
            };
        }
Exemple #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif

            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";
            Button.TouchUpInside          += delegate
            {
                var title = string.Format("{0} clicks!", count++);
                Button.SetTitle(title, UIControlState.Normal);

                // Configure API key authorization: key
                Configuration.Default.ApiKey.Add("apikey", "YOUR_API_KEY");
                // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
                // Configuration.Default.ApiKeyPrefix.Add("apikey", "Bearer");

                var apiInstance = new AlbumApi();
                var albumId     = "14250417";         // string | The musiXmatch album id
                var format      = "json";             // string | output format: json, jsonp, xml. (optional)  (default to json)

                try
                {
                    //
                    InlineResponse200 result = apiInstance.AlbumGetGet(albumId, format);
                    var res = JsonConvert.SerializeObject(result);
                    Console.WriteLine(res);
                }
                catch (IO.Swagger.Client.ApiException e)
                {
                    Console.WriteLine("Exception when calling DefaultApi.AlbumGetGet: " + e.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception when calling DefaultApi.AlbumGetGet: " + e.Message);
                }
            };
        }