/// <summary>Creates a new object that is a copy of the current instance.</summary> /// <returns>A new object that is a copy of this instance.</returns> /// <exception cref="NotImplementedException"></exception> public virtual object Clone() { return(new ErrorMessage() { RawMessage = RawMessage, FilePath = FilePath, HttpMethod = HttpMethod, RequestId = RequestId, Url = Url != null ? new Uri(Url.ToString()) : null, UrlReferrer = UrlReferrer != null ? new Uri(UrlReferrer.ToString()) : null, AdditionalData = AdditionalData?.ToDictionary(x => x.Key, x => x.Value) }); }
public ChannelAttributesManagerTests_GetTitleTests() { _urlReferrer = new UrlReferrer { Id = 4, Host = "SomeHost.some" }; _urlReferrerRepositoryMock .Setup(m => m.GetByIdAsync(_urlReferrer.Id)) .ReturnsAsync(_urlReferrer); _manager = new ChannelAttributesManager( _channelAttributesRepositoryMock.Object, _urlReferrerRepositoryMock.Object, _channelRepositoryMock.Object); }
protected internal async Task <object> InvokeAction() { SetHeader("Last-Modified", DateTime.Now.ToString("r")); //跨域 if (UrlReferrer != null && Uri.Compare(UrlReferrer, Url, UriComponents.SchemeAndServer, UriFormat.Unescaped, StringComparison.OrdinalIgnoreCase) != 0 && HeaderContains("X-CrossDomain", "true")) { SetHeader("Access-Control-Allow-Credentials", "true"); SetHeader("Access-Control-Allow-Origin", UrlReferrer.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped)); } else { SetHeader("Access-Control-Allow-Origin", "*"); SetHeader("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS"); SetHeader("Access-Control-Allow-Headers", "Accept, Origin, XRequestedWith, Content-Type, LastModified,Access-Token"); } var etag = RequestValues.Headers["If-None-Match"]; if (etag != null && Cache[etag] != null) { return(NotModifiedResult.Instance); } Exception apiError; try { InitAgent(); RewriteReferrer(); return(SaveSession(await ActionInvoker())); } catch (Exception e) { apiError = e; } var task = OnExecuteError(ActionName, apiError); var r = task == null ? null : await task; return(SaveSession(r ?? ErrorResult(apiError))); }
public async Task AddOrUpdateAsync(UrlReferrer urlReferrer) { await _dbContext.UrlReferrers.InsertOrUpdateAsync( () => new UrlReferrerDb { ChannelId = urlReferrer.ChannelId, Host = urlReferrer.Host, IsDeleted = false }, dbValue => new UrlReferrerDb { IsDeleted = false, ChannelId = urlReferrer.ChannelId ?? dbValue.ChannelId }, () => new UrlReferrerDb { Host = urlReferrer.Host } ); _distributedCache.Delete(WhiteListCacheKey); }
public UrlReferrerDto(UrlReferrer urlReferrer) { Host = urlReferrer.Host; ChannelId = urlReferrer.ChannelId; }