2

Эй, я пытаюсь сделать универсальное приложение для платформы Windows, в котором находится календарь Google, но я не могу понять, как преобразовать код, я получил код для работы в приложении WPF. Я не лучший при кодировании https://developers.google.com/google-apps/calendar/quickstart/dotnet Это сайт, который я использую в качестве ориентира в начале, если он поможет любой помощи, любой помощи? код ниже:Универсальное приложение для платформы Windows с календарем Google

using System; 
using System.Collections.Generic; 
using System.IO; 
using System.Linq; 
using System.Text; 
using System.Threading; 
using System.Threading.Tasks; 
using Google.Apis.Auth.OAuth2; 
using Google.Apis.Calendar.v3; 
using Google.Apis.Calendar.v3.Data; 
using Google.Apis.Services; 
using Google.Apis.Util.Store; 

namespace Test1UWA 
{ 
    class GoogleEvents4 
    { 
     public string Title { get; set; } 
     public DateTime? StartDate { get; set; } 
     public DateTime? EndDate { get; set; } 
    } 

    class GoogleClass4 
    { 
     public List<GoogleEvents4> GoogleEvents = new List<GoogleEvents4>(); 

     static string[] Scopes = { CalendarService.Scope.CalendarReadonly }; 
     static string ApplicationName = "Google Calendar API .NET Quickstart"; 



     public GoogleClass4() 
     { 
      UserCredential credential; 

      using (var stream = 
          new FileStream("client_secret4.json", FileMode.Open, FileAccess.Read)) 
      { 
       string credPath = System.Environment.GetFolderPath(
        System.Environment.SpecialFolder.Personal); 
       credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart.json"); 

       credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
        GoogleClientSecrets.Load(stream).Secrets, 
        Scopes, 
        "user", 
        CancellationToken.None, 
        new FileDataStore(credPath, true)).Result; 

      } 
      // Create Google Calendar API service. 
      var service = new CalendarService(new BaseClientService.Initializer() 
      { 
       HttpClientInitializer = credential, 
       ApplicationName = ApplicationName, 
      }); 

      // Define parameters of request. 
      EventsResource.ListRequest request = service.Events.List("primary"); 
      request.TimeMin = DateTime.Now; 
      request.ShowDeleted = true; 
      request.SingleEvents = true; 
      request.MaxResults = 10; 
      request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; 

      // List events. 
      Events events = request.Execute(); 
      if (events.Items != null && events.Items.Count > 0) 
      { 
       foreach (var eventItem in events.Items) 
       { 
        string when = eventItem.Start.DateTime.ToString(); 
        if (String.IsNullOrEmpty(when)) 
        { 
         when = eventItem.Start.Date; 
        } 

        GoogleEvents.Add(new GoogleEvents4 { Title = eventItem.Summary, StartDate = eventItem.Start.DateTime, EndDate = eventItem.End.DateTime }); 


       } 
      } 
     } 
    } 
} 
+0

«Конвертировать код»? Я не вижу ничего конкретного WPF или UWP в примере, который вы опубликовали. Какая у вас проблема, * точно *? – Dai

+0

моя проблема: GetFolderPath, SpecialFolder и FileDataStore недоступны в UWP –

+0

Вы хотите использовать UWP-файл em API, см. здесь: http://stackoverflow.com/questions/33082835/windows-10-universal-app-file-directory-access – Dai

ответ

1

В это время в Google .net библиотеки Клиент не поддерживает UWP.

Ссылка с client library (supported platform list)

chrisdunelm 27 дней назад член Google К сожалению, мы не поддерживаем UWP еще, поэтому он не может быть в списке пока нет. Может быть, мы должны подчеркнуть , что мы не поддерживаем его :(

Update:

Мы планируем поддерживать UWP в выпуске v2.0, который, мы надеемся, будет в начале 2017.