public string Build() { var sb = new StringBuilder(); sb.Append(_scheme); sb.Append("://"); if (_username != null) { sb.Append(_urlEncoder.Encode(_username)); if (_password != null) { sb.Append($":{_urlEncoder.Encode(_password)}"); } sb.Append("@"); } sb.Append(_host); if (_port != null) { sb.Append($":{_port}"); } foreach (var segment in _segments) { sb.Append("/"); sb.Append(segment); } if (_nameValueCollection.Count == 0) { return(sb.ToString()); } sb.Append("?"); sb.Append(_nameValueCollection .Select(i => $"{_urlEncoder.Encode(i.Key)}={_urlEncoder.Encode(i.Value)}") .ToSeparatedString("&")); return(sb.ToString()); }
/// <summary> /// Merges the specified assets. /// </summary> /// <param name="contentType">Type of the content.</param> /// <param name="assetHandlerPath">The asset handler path.</param> /// <param name="isSecured">if set to <c>true</c> [is secure].</param> /// <param name="canCompress">if set to <c>true</c> [can compress].</param> /// <param name="assets">The assets.</param> /// <returns>The collection of web asset paths.</returns> public IList <string> Merge(string contentType, string assetHandlerPath, bool isSecured, bool canCompress, WebAssetItemCollection assets) { // If the instance object is null. if (contentType == null) { throw new System.ArgumentNullException("contentType"); } if (assetHandlerPath == null) { throw new System.ArgumentNullException("assetHandlerPath"); } if (assets == null) { throw new System.ArgumentNullException("assets"); } IList <string> mergedList = new List <string>(); Func <string, string, string> getRelativePath = (source, version) => _urlResolver.Resolve(_assetRegistry.Locate(source, version)); Action <WebAssetItemGroup> processGroup = group => { if (group.Combined) { string id = _assetRegistry.Store(contentType, group); string virtualPath = "{0}?{1}={2}".FormatWith(assetHandlerPath, _urlEncoder.Encode(WebAssetHttpHandler.IdParameterName), _urlEncoder.Encode(id)); string relativePath = _urlResolver.Resolve(virtualPath); if (!mergedList.Contains(relativePath, StringComparer.OrdinalIgnoreCase)) { mergedList.Add(relativePath); } } else { group.Items.Each(i => { if (!mergedList.Contains(i.Source, StringComparer.OrdinalIgnoreCase)) { mergedList.Add(getRelativePath(i.Source, group.Version)); } }); } }; if (!assets.IsEmpty()) { foreach (IWebAssetItem asset in assets) { WebAssetItem item = asset as WebAssetItem; WebAssetItemGroup itemGroup = asset as WebAssetItemGroup; if (item != null) { mergedList.Add(getRelativePath(item.Source, null)); } else if (itemGroup != null) { WebAssetItemGroup frameworkGroup = null; if ((frameworkGroup != null) && !frameworkGroup.Items.IsEmpty()) { processGroup(frameworkGroup); } if (!itemGroup.Items.IsEmpty()) { processGroup(itemGroup); } } } } // Return the list. return(mergedList.ToList()); }
public async Task <ActionResponse> RegisterAsync(RegisterModel model) { var user = new User { Email = model.Email, Name = model.Name, UserName = Guid.NewGuid().ToString() }; var savedUser = await _userManager.CreateAsync(user, model.Password); if (!savedUser.Succeeded) { _logger.LogCritical($"User creation failed {JsonConvert.SerializeObject(savedUser.Errors)}"); return(ToActionResponse(savedUser.Errors)); } var token = new InvitationToken { Email = model.Email, Token = Encryptor.EncryptText(model.Email, _appSettings.EncryptionKey) }; await _invitationTokenRepository.AddAsync(token); _emailSender.SendEmail(model.Email, $"Hello {model.Name}, <br /> In order to activate your " + $"account please click here: https://localhost:5003/user/activate?activationToken={_urlEncoder.Encode(token.Token)}" + $"<br/> <br/>Thank you, <br/>Galaxy team", "Please activate your account"); return(new ActionResponse()); }