public HomeController()
 {
     _bingApiKey              = ConfigurationManager.AppSettings["BingApiKey"];
     _daysToCache             = Convert.ToInt32(ConfigurationManager.AppSettings["MeetingJsonDayspan"]);
     _dateToCache             = DateTime.Now.AddDays(_daysToCache);
     _bingClient              = new BingClient(_bingApiKey);
     _aaClient                = new AAClient();
     _caClient                = new CAClient();
     _naClient                = new NAClient();
     _filterAndSortingUtility = new FilterAndSortingUtility();
 }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // 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);

            this.cancellation = new CancellationTokenSource();
            var reachability = new Reachability();

            reachability.Ping("http://www.yahoo.com", cancellation.Token, this).ContinueWith(t =>
            {
                Log.Info(t.ToString(), "Ping has ended");
            });

            reachability.IsHostReachable("http://dev.virtualearth.net", TimeSpan.FromMinutes(1)).ContinueWith(t =>
            {
                button.Enabled = t.Result;
            });

            DependencyResolver.Current.RegisterService <IJsonSerializer>(new SimplyMobile.Text.JsonNet.JsonSerializer());
            DependencyResolver.Current.RegisterService <IRestClient>(t =>
                                                                     new JsonClient(new HttpClient(new OkHttpNetworkHandler()),
                                                                                    t.GetService <IJsonSerializer>())
                                                                     );

            button.Click += async delegate
            {
                var bingClient = new BingClient(
                    "Apcl0Dzk-uwuqlIpDPjGLaA0oHXERDiGBuE3Vzxx3peRCr8gmSRPr-J6cij7U1pZ",
                    DependencyResolver.Current.GetService <IRestClient>()
                    );

                var response = await bingClient.Get(47.64054, -122.12934);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    System.Diagnostics.Debug.WriteLine(response.Value.Copyright);
                    CreateIntent(response.Value);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(response.Error.Message);
                }
            };
        }
Exemple #3
0
        private BingClient SetUpBingClient()
        {
            var services = SetUpBingServiceCollection();

            var httpClient = SetUpBingHttpClient();

            var nullLogger      = Microsoft.Extensions.Logging.Abstractions.NullLogger <BingClient> .Instance;
            var serviceProvider = services.BuildServiceProvider();
            var mapper          = serviceProvider.GetRequiredService <IMapper>();

            var bingClient = new BingClient(httpClient, serviceProvider.GetRequiredService <BingClientSettings>(), mapper, nullLogger);

            return(bingClient);
        }