示例#1
0
        /// <summary>
        /// Prevents a default instance of the <see cref="IdHasher"/> class from being created.
        /// </summary>
        private IdHasher()
        {
            // Initialize the hasher with the encryption key trimmed down to an
            // acceptable length. The salt must be shorter than the length of
            // the available characters.
            var salt = ConfigurationManager.AppSettings["DataEncryptionKey"].Left(40);

            _hasher = new Hashids(salt, 10);
        }
示例#2
0
 public PileOperationsController(IPileCardsInterractor pileCardsInterractor,
                                 IMapper mapper,
                                 IDeckRepository deckRepository,
                                 IHashids hashids)
 {
     _pileCardsInterractor = pileCardsInterractor;
     _mapper         = mapper;
     _deckRepository = deckRepository;
     _hashids        = hashids;
 }
        public static IServiceCollection AddHashids(this IServiceCollection services, Action<HashidsOptions> setup)
        {
            services.Configure(setup);
            services.AddSingleton(sp => sp.GetRequiredService<IOptions<HashidsOptions>>().Value);
            services.AddSingleton<IConfigureOptions<JsonOptions>, ConfigureJsonOptions>();
            services.AddSingleton(sp =>
            {
                var options = sp.GetRequiredService<HashidsOptions>();
                Hashids = new Hashids(options.Salt, options.MinHashLength, options.Alphabet, options.Steps);
                return Hashids;
            });

            services.PostConfigure<RouteOptions>(setup =>
            {
                setup.ConstraintMap.Add("hashids", typeof(HashidsRouteConstraint));
            });
            return services;
        }
示例#4
0
 public DeckRepository(ILiteDbContext context, IHashids hashids)
 {
     db       = context.Database;
     _hashids = hashids;
 }
 public void Setup()
 {
     hashService = new Hashids("this is a test salt", 5);
 }
示例#6
0
 public RpgCharacterCombatController(IMediator mediator, IHashids hashids)
 {
     this.mediator = mediator;
     this.hashids  = hashids;
 }
 public HashIdGenerator(IHashids hashGenerator)
 {
     this.hashGenerator = hashGenerator;
 }
示例#8
0
 public HashidsRouteConstraint(IHashids hashids)
 {
     this.hashids = hashids ?? throw new ArgumentNullException(nameof(hashids));
 }
示例#9
0
 public HashidsModelBinder(IHashids hashids)
 {
     this.hashids = hashids ?? throw new System.ArgumentNullException(nameof(hashids));
 }
示例#10
0
 public PileCardsInterractor(IDeckRepository deckRepository, ICardsHelper cardsHelper, IHashids hashids)
 {
     _deckRepository = deckRepository;
     _cardsHelper    = cardsHelper;
     _hashids        = hashids;
 }
 public RpgCharacterCombatControllerShould()
 {
     mediator   = Substitute.For <IMediator>();
     hashids    = Substitute.For <IHashids>();
     controller = new RpgCharacterCombatController(mediator, hashids);
 }
示例#12
0
 public ShortLinkService(IConfiguration configuration, IDataProvider dataProvider, IHashids hashids)
 {
     _configuration = configuration;
     _dataProvider  = dataProvider;
     _hashids       = hashids;
 }