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); }
/// <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); } } }
/// <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)); } }
/// <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; } } }
public void Update(IDirectResponseSchema newCalendarEvent, string calendarId, string oldEventId) { try { _taskRepository.Update(newCalendarEvent, calendarId, oldEventId); } catch(Exception ex) { throw ex; } }
public void Add(string calendarId, IDirectResponseSchema body) { try { _taskRepository.Add(calendarId, body); } catch(Exception ex) { throw ex; } }
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; } }
/// <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; } } }
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")); }
public void ValidateModel(IDirectResponseSchema taskModel) { _modelDataAnnotationCheck.ValidateModelDataAnnotations(taskModel); ValidateTaskTimeOfCreation(taskModel); }
public void ValidateModelDataAnnotations(IDirectResponseSchema taskModel) { _modelDataAnnotationCheck.ValidateModelDataAnnotations(taskModel); }
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")); }
public void Update(IDirectResponseSchema newCalendarEvent, string calendarId, string oldEventId) { var _newCalendarEvent = newCalendarEvent as Event; EventsResource.UpdateRequest request = service.Events.Update(_newCalendarEvent, calendarId, oldEventId); }