Esempio n. 1
0
 private void UpdateDefaultOauthParameters()
 {
     OauthParameters["nonce"]            = RngHelper.GetRandomHexString(10);
     OauthParameters["timestamp"]        = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
     OauthParameters["consumer_key"]     = _consumerKey;
     OauthParameters["signature_method"] = SignatureMethod;
     OauthParameters["version"]          = Version;
 }
        public static void Shuffle <T>(this IList <T> list)
        {
            int listCount = list.Count;

            while (listCount > 1)
            {
                listCount--;
                int randomIndex = RngHelper.GetRandom(0, listCount + 1);
                T   value       = list[randomIndex];
                list[randomIndex] = list[listCount];
                list[listCount]   = value;
            }
        }
Esempio n. 3
0
        public async Task <UserAccessToken> CreateUserAccessTokenAsync(int userId, CreateAccessTokenRequest request)
        {
            using (var uow = _unitOfWorkFactory.CreateUnitOfWork())
            {
                var token = new UserAccessToken
                {
                    Id          = Guid.NewGuid(),
                    Key         = RngHelper.GetRandomHexString(64),
                    Name        = request.Name,
                    UserId      = userId,
                    DateCreated = _timeService.UtcNow
                };
                uow.UserAccessTokenRepository.Add(token);
                await uow.SaveChangesAsync();

                return(token);
            }
        }
Esempio n. 4
0
 public int GetRandomInt(int min, int max)
 {
     return(RngHelper.GetRandomInt(min, max));
 }
Esempio n. 5
0
 public int GetRandomInt()
 {
     return(RngHelper.GetRandomInt());
 }
Esempio n. 6
0
 public string GetRandomString(string prefix)
 {
     return(RngHelper.GetRandomString(prefix));
 }
Esempio n. 7
0
 public string GetRandomHexString(int byteCount)
 {
     return(RngHelper.GetRandomHexString(byteCount));
 }