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 ... }
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); }
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()); }
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; }
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."); }
public MongoUserProvider(IEngineCensoContext context, IHashingAlgorithm hashingAlgorithm) { this.context = context; this.hashingAlgorithm = hashingAlgorithm; }
public CachingSimilarityAlgorithm(ICacheService <T> cacheService, IHashingAlgorithm <T> hashingAlgorithm) { CacheService = cacheService; HashingAlgorithm = hashingAlgorithm; }
public UserAuthService(IHashingAlgorithm hashingAlgorithm, IUserRepository userRepository, ILogger logger) { _hashingAlgorithm = hashingAlgorithm; _userRepository = userRepository; _logger = logger; }
// injection in constructor public SomeBusinessLogic(IHashingAlgorithm hashing) { // put hashing in a field of the class }
public static ISimilarityAlgorithm WithCache <T>(this IHashingAlgorithm <T> alg) { var ramCache = new RamCacheService <T>(); return(new CachingSimilarityAlgorithm <T>(ramCache, alg)); }
public CreateFirstUser(IUserRepository userRepository, ILogger logger, IHashingAlgorithm hashingAlgorithm) { _userRepository = userRepository; _logger = logger; _hashingAlgorithm = hashingAlgorithm; }
public EngineCensoContextInitializer(IEngineCensoContext context, IHashingAlgorithm hashingAlgorithm) { this.context = context; this.hashingAlgorithm = hashingAlgorithm; }