Exemplo n.º 1
0
        public static ISimilarityAlgorithm WithPersistentCache <T>(this IHashingAlgorithm <T> alg, IFileDataStorage storage)
            where T : IBinarySerializable, new()
        {
            var cache = new PersistentCacheService <T>(storage, alg.Name);

            return(new CachingSimilarityAlgorithm <T>(cache, alg));
        }
    // OR injection in method itself, if hashing is only used in this method
    public Result HandleDocument(IDocument doc, IHashingAlgorithm hashing)
    {
        // some transformations...

        int hash = hashing.CalculateHash(seed, doc.Properties);

        // some other code ...
    }
Exemplo n.º 3
0
        public static byte[] GenerateHashedByteValue(this Event e, IHashingAlgorithm hashingAlgorithm)
        {
            var eventObjAsStringArray = ConverMembersToStringArray(e);
            var eventObjAsString      = string.Join(",", eventObjAsStringArray);
            var eventObjAsByteArray   = Encoding.ASCII.GetBytes(eventObjAsString);
            var hashedByteArray       = hashingAlgorithm.ComputeHash(eventObjAsByteArray);

            return(hashedByteArray);
        }
Exemplo n.º 4
0
        public static string IterateOverEventExecutingAction(this Event e, IHashingAlgorithm hashingAlgorithm)
        {
            var hashedByteArray = GenerateHashedByteValue(e, hashingAlgorithm);

            StringBuilder sb = new StringBuilder();

            sb.Clear();
            hashedByteArray.ToList().ForEach(r =>
            {
                sb.Append(r.ToString());
            });
            return(sb.ToString());
        }
Exemplo n.º 5
0
        public void CompositeRoot(IHashingAlgorithm hashingAlgorithm)
        {
            // var dataService = new FakeBaxSummaryDataService();
            // SecretCreds is a non-source-controlled file to store the two AWS credential values.
            var dataService = new AmazonS3BaxSummaryDataService(hashingAlgorithm, SecretCreds.AwsAccessKeyId, SecretCreds.AwsSecret);
            var dataManager = new MobileSummaryDataManager(dataService);

            var mainViewModel = new MainViewModel(
                new OverviewViewModel(dataManager),
                new BucketsListViewModel(dataManager),
                dataManager
                );

            MainPage = new MainPage {
                BindingContext = mainViewModel
            };
        }
 public AmazonS3BaxSummaryDataService([NotNull] IHashingAlgorithm hashingAlgorithm, [NotNull] string accessKey, [NotNull] string secret)
 {
     if (hashingAlgorithm == null)
     {
         throw new ArgumentNullException(nameof(hashingAlgorithm));
     }
     if (accessKey == null)
     {
         throw new ArgumentNullException(nameof(accessKey));
     }
     if (secret == null)
     {
         throw new ArgumentNullException(nameof(secret));
     }
     this.hashingAlgorithm = hashingAlgorithm;
     this.accessKey        = accessKey;
     this.secret           = secret;
 }
Exemplo n.º 7
0
        public ImportProcess(int millisecondsToSleep, IIntervalCalculator intervalCalculator,
                             IHashingAlgorithm hashingAlgorithm,
                             IApiEndPointService apiEndPointService,
                             INewRelicService newRelicService,
                             IRootObjectService rootObjectService,
                             IEventService eventService)
        {
            _millisecondsToSleep = millisecondsToSleep;
            _intervalCalculator  = intervalCalculator;
            _hashingAlgorithm    = hashingAlgorithm;
            _newRelicService     = newRelicService;
            _rootObjectService   = rootObjectService;
            _eventService        = eventService;
            _apiEndPointService  = apiEndPointService;

            HistoricalEvents   = _eventService.GetEvents()?.ToList();
            HistoricalWorkLoad = new Stack <NewRelicHttpRequest>();
            CurrentWorkLoad    = new Stack <NewRelicHttpRequest>();

            Console.WriteLine("ImportProcess created.");
        }
Exemplo n.º 8
0
 public MongoUserProvider(IEngineCensoContext context, IHashingAlgorithm hashingAlgorithm)
 {
     this.context          = context;
     this.hashingAlgorithm = hashingAlgorithm;
 }
 public CachingSimilarityAlgorithm(ICacheService <T> cacheService, IHashingAlgorithm <T> hashingAlgorithm)
 {
     CacheService     = cacheService;
     HashingAlgorithm = hashingAlgorithm;
 }
Exemplo n.º 10
0
 public UserAuthService(IHashingAlgorithm hashingAlgorithm, IUserRepository userRepository, ILogger logger)
 {
     _hashingAlgorithm = hashingAlgorithm;
     _userRepository   = userRepository;
     _logger           = logger;
 }
Exemplo n.º 11
0
 // injection in constructor
 public SomeBusinessLogic(IHashingAlgorithm hashing)
 {
     // put hashing in a field of the class
 }
Exemplo n.º 12
0
        public static ISimilarityAlgorithm WithCache <T>(this IHashingAlgorithm <T> alg)
        {
            var ramCache = new RamCacheService <T>();

            return(new CachingSimilarityAlgorithm <T>(ramCache, alg));
        }
Exemplo n.º 13
0
 public CreateFirstUser(IUserRepository userRepository, ILogger logger, IHashingAlgorithm hashingAlgorithm)
 {
     _userRepository   = userRepository;
     _logger           = logger;
     _hashingAlgorithm = hashingAlgorithm;
 }
Exemplo n.º 14
0
 public EngineCensoContextInitializer(IEngineCensoContext context, IHashingAlgorithm hashingAlgorithm)
 {
     this.context          = context;
     this.hashingAlgorithm = hashingAlgorithm;
 }