Exemplo n.º 1
0
 public YoutubeItem(String title, IDirectResponseSchema result, int relevance) :
     base(null, title)
 {
     Title = title;
     Info = result;
     Relevance = relevance;
 }
        internal IRequest BuildRequest()
        {
            IRequest request = service.CreateRequest(this);

            request.WithBody(GetSerializedBody());
            request.WithParameters(CreateParameterDictionary());
            request.WithETagAction(ETagAction);

            // Check if there is an ETag to attach.
            if (!string.IsNullOrEmpty(ETag))
            {
                request.WithETag(ETag);
            }
            else
            {
                // If no custom ETag has been set, try to use the one which might come with the body.
                // If this is a ISchemaResponse, the etag has been added to the object as it was created.
                IDirectResponseSchema body = GetBody() as IDirectResponseSchema;
                if (body != null)
                {
                    request.WithETag(body.ETag);
                }
            }

            return(request);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the right ETag action (e.g. If-Match) header to the given HTTP request if the body contains ETag.
        /// </summary>
        private void AddETag(HttpRequestMessage request)
        {
            IDirectResponseSchema body = GetBody() as IDirectResponseSchema;

            if (body != null && !string.IsNullOrEmpty(body.ETag))
            {
                var        etag   = body.ETag;
                ETagAction action = ETagAction == ETagAction.Default ? GetDefaultETagAction(HttpMethod) : ETagAction;
                try
                {
                    switch (action)
                    {
                    case ETagAction.IfMatch:
                        request.Headers.IfMatch.Add(new EntityTagHeaderValue(etag));
                        break;

                    case ETagAction.IfNoneMatch:
                        request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(etag));
                        break;
                    }
                }
                // When ETag is invalid we are going to create a request anyway.
                // See https://code.google.com/p/google-api-dotnet-client/issues/detail?id=464 for more details.
                catch (FormatException ex)
                {
                    Logger.Error(ex, "Can't set {0}. Etag is: {1}.", action, etag);
                }
            }
        }
Exemplo n.º 4
0
 public YoutubeItem(String title, IDirectResponseSchema result, int relevance) :
     base(null, title)
 {
     Title     = title;
     Info      = result;
     Relevance = relevance;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Logs a YouTube service response
 /// </summary>
 /// <typeparam name="T">The type of the request</typeparam>
 /// <param name="request">The request to log</param>
 /// <param name="response">The response to log</param>
 protected void LogResponse <T>(YouTubePartnerBaseServiceRequest <T> request, IDirectResponseSchema response)
 {
     if (Logger.Level == LogLevel.Debug)
     {
         Logger.Log(LogLevel.Debug, "Rest API Request Complete: " + request.RestPath + " - " + JSONSerializerHelper.SerializeToString(response));
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Adds the right ETag action (e.g. If-Match) header to the given HTTP request if the body contains ETag.
        /// </summary>
        private void AddETag(HttpRequestMessage request)
        {
            IDirectResponseSchema body = GetBody() as IDirectResponseSchema;

            if (body != null && !string.IsNullOrEmpty(body.ETag))
            {
                var        etag   = body.ETag;
                ETagAction action = ETagAction == ETagAction.Default ? GetDefaultETagAction(HttpMethod) : ETagAction;
                // TODO: ETag-related headers are added without validation at the moment, because it is known
                // that some services are returning unquoted etags (see rfc7232).
                // Once all services are fixed, change back to the commented-out code that validates the header.
                switch (action)
                {
                case ETagAction.IfMatch:
                    //request.Headers.IfMatch.Add(new EntityTagHeaderValue(etag));
                    request.Headers.TryAddWithoutValidation("If-Match", etag);
                    break;

                case ETagAction.IfNoneMatch:
                    //request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(etag));
                    request.Headers.TryAddWithoutValidation("If-None-Match", etag);
                    break;
                }
            }
        }
Exemplo n.º 7
0
 public void Update(IDirectResponseSchema newCalendarEvent, string calendarId, string oldEventId)
 {
     try
     {
         _taskRepository.Update(newCalendarEvent, calendarId, oldEventId);
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
 public void Add(string calendarId, IDirectResponseSchema body)
 {
     try
     {
         _taskRepository.Add(calendarId, body);
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 9
0
 public void Add(string calendarId, IDirectResponseSchema newCalendarEvent)
 {
     try
     {
         var body = newCalendarEvent as Event;
         EventsResource.InsertRequest request = service.Events.Insert(body, calendarId);
         request.Execute();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Adds the right ETag action (e.g. If-Match) header to the given HTTP request if the body contains ETag.
        /// </summary>
        private void AddETag(HttpRequestMessage request)
        {
            IDirectResponseSchema body = GetBody() as IDirectResponseSchema;

            if (body != null && !string.IsNullOrEmpty(body.ETag))
            {
                ETagAction action = ETagAction == ETagAction.Default ? GetDefaultETagAction(HttpMethod) : ETagAction;
                switch (action)
                {
                case ETagAction.IfMatch:
                    request.Headers.IfMatch.Add(new EntityTagHeaderValue(body.ETag));
                    break;

                case ETagAction.IfNoneMatch:
                    request.Headers.IfNoneMatch.Add(new EntityTagHeaderValue(body.ETag));
                    break;
                }
            }
        }
Exemplo n.º 11
0
        public MainPresenter(IMainView mainView)
        {
            CurrentDate         = DateTime.Now;
            _mainView           = mainView;
            _eventGoogleService = new TaskService(new TaskGoogleRepository(), null);

            _calendarEventsParser = new CalendarEventsParser();
            CurrentDate           = DateTime.Now;

            _calendarEvents = GetDataFromLocalRepository();
            LoadTasksArray();

            _mainView.InitializeDays(CurrentDate, width, height + sizeY / 2, sizeX, sizeY);
            _mainView.InitializeLabelsOWeekfDays(countOfDaysInWeek, width, height, sizeX);
            _mainView.InitializeDateLabels(width, height, sizeX, sizeY, CurrentDate);
            _mainView.InitializeLeftArrow(sizeX, sizeY);
            _mainView.InitializeRightArrow(sizeX, sizeY);
            _mainView.InitializeToolTips(tasksArray);
            _mainView.HighlightDaysButtonsWithTasks(tasksArray);
            _mainView.InitializeNotifyIcon();
            SubscribeToEventsSetup();
        }
 public static PageInfo GetPageInfo(this IDirectResponseSchema response)
 {
     return(response.GetPropertyValue <PageInfo>("PageInfo"));
 }
Exemplo n.º 13
0
 public void ValidateModel(IDirectResponseSchema taskModel)
 {
     _modelDataAnnotationCheck.ValidateModelDataAnnotations(taskModel);
     ValidateTaskTimeOfCreation(taskModel);
 }
Exemplo n.º 14
0
 public void ValidateModelDataAnnotations(IDirectResponseSchema taskModel)
 {
     _modelDataAnnotationCheck.ValidateModelDataAnnotations(taskModel);
 }
Exemplo n.º 15
0
 public void ValidateTaskTimeOfCreation(IDirectResponseSchema taskModel)
 {
     // some code to validate timeofcreation
 }
 public static string GetNextPageToken(this IDirectResponseSchema response)
 {
     return(response.GetPropertyValue <string>("NextPageToken"));
 }
 public static IList <TResponseItem> GetResponseItems <TResponseItem>(this IDirectResponseSchema response)
 {
     return(response.GetPropertyValue <IList <TResponseItem> >("Items"));
 }
Exemplo n.º 18
0
        public void Update(IDirectResponseSchema newCalendarEvent, string calendarId, string oldEventId)
        {
            var _newCalendarEvent = newCalendarEvent as Event;

            EventsResource.UpdateRequest request = service.Events.Update(_newCalendarEvent, calendarId, oldEventId);
        }