/// <summary> /// Equality method between two objects of the same type. /// Because the Equals method is strongly typed by generic constraints, /// it is not necessary to test for the correct object type. /// For safety we just want to match on business key value - in this case the fields /// that cannot be different between the two objects if they are supposedly equal. /// </summary> /// <param name="obj">The other object of this type that we are testing equality with</param> /// <returns></returns> public virtual bool Equals(ApplicationInformation <TIdType> obj) { if (obj != null) { // Transient objects are not considered as equal if (IsTransient() && obj.IsTransient()) { return(false); } else { // For safe equality we need to match on business key equality. // Base domain entities are functionally equal if their key and metadata and tags are equal. // Subclasses should extend to include their own enhanced equality checks, as required. if (TenantId != null) { return(Id.Equals(obj.Id) && Culture.Equals(obj.Culture) && ApplicationKey.Equals(obj.ApplicationKey) && Name.Equals(obj.Name)); } else { return(Id.Equals(obj.Id) && Culture.Equals(obj.Culture) && ApplicationKey.Equals(obj.ApplicationKey) && Name.Equals(obj.Name) && TenantId.Equals(obj.TenantId)); } } } return(false); }
public void SetDataToCacheWithEmptyKeyThrows() { var cache = CreateCache(); var key = new ApplicationKey(""); var value = new object(); Assert.Throws <ArgumentNullException>(() => cache.Set <object>(key, value)); }
public void GetMissingKeyReturnsNull() { var cache = CreateCache(); var key = new ApplicationKey("key"); var result = cache.Get <object>(key); Assert.Null(result); }
public void AddMasterData(ApplicationKey document) { if (document.Id == string.Empty) { document.Id = Guid.NewGuid().ToString(); } collectionApplicationKey.InsertOne(document); }
public async Task GetOrSetAsync_ReturnExistingValue() { var cache = CreateCache(); var obj = new object(); var key = new ApplicationKey("key"); cache.Set <object>(key, obj); var result = await cache.GetOrSetAsync <object>(key, obj); Assert.Same(obj, result); }
public override int GetHashCode() { return (AbsoluteMinimumPartSize.GetHashCode() ^ AccountID.GetHashCode() ^ APIURL.GetHashCode() ^ ApplicationKey.GetHashCode() ^ AuthorizationToken.GetHashCode() ^ DownloadURL.GetHashCode() ^ RecommendedPartSize.GetHashCode() ^ SessionExpirationDate.GetHashCode()); }
public void GetOrSet_AddsNewValue() { var cache = CreateCache(); var obj = new object(); var key = new ApplicationKey("key"); var result = cache.GetOrSet <object>(key, obj); Assert.Same(obj, result); result = cache.Get <object>(key); Assert.Same(obj, result); }
public void GetOrCreate_ReturnExistingValue() { var cache = CreateCache(); var obj = new object(); var key = new ApplicationKey("key"); var invoked = false; cache.Set <object>(key, obj); var result = cache.GetOrSet <object>(key, obj); Assert.False(invoked); Assert.Same(obj, result); }
public void RemoveRemoves() { var cache = CreateCache(); var obj = new object(); var key = new ApplicationKey("key"); var result = cache.Set <object>(key, obj); Assert.Same(obj, result); cache.Remove <object>(key); result = cache.Get <object>(key); Assert.Null(result); }
public void GetOrSetWorksWithCaseSensitiveKeys() { var cache = CreateCache(); var obj = new object(); var key1 = new ApplicationKey("key"); var key2 = new ApplicationKey("Key"); var result = cache.GetOrSet <object>(key1, obj); Assert.Same(obj, result); result = cache.Get <object>(key1); Assert.Same(obj, result); result = cache.Get <object>(key2); Assert.Null(result); }
public bool Equals(BackblazeB2AuthorizationSession other) { if (EqualsPreamble(other) == false) { return(false); } return (AbsoluteMinimumPartSize == other.AbsoluteMinimumPartSize && AccountID.Equals(other.AccountID, StringComparison.Ordinal) && APIURL.Equals(other.APIURL, StringComparison.Ordinal) && ApplicationKey.Equals(other.ApplicationKey, StringComparison.Ordinal) && AuthorizationToken.Equals(other.AuthorizationToken, StringComparison.Ordinal) && DownloadURL.Equals(other.DownloadURL, StringComparison.Ordinal) && RecommendedPartSize == other.RecommendedPartSize && SessionExpirationDate.Equals(other.SessionExpirationDate)); }
public void SetAlwaysOverwrites() { var cache = CreateCache(); var obj = new object(); var key = new ApplicationKey("key"); var result = cache.Set <object>(key, obj); Assert.Same(obj, result); var obj2 = new object(); result = cache.Set <object>(key, obj2); Assert.Same(obj2, result); result = cache.Get <object>(new ApplicationKey("key")); Assert.Same(obj2, result); }
/// <summary> /// Computes and retrieves a hash code for an object. /// </summary> /// <remarks> /// This method implements the <see cref="Object">Object</see> method. /// </remarks> /// <returns>A hash code for an object.</returns> public override int GetHashCode() { return(Id.GetHashCode() + Culture.GetHashCode() + ApplicationKey.GetHashCode()); }
public ActionResult UsuarioLogin([FromBody] ApplicationKey aplicacion) { ServiceResult service = new ServiceResult(); try { if (!string.IsNullOrEmpty(aplicacion.key)) { var aplicacionKey = StringCipher.Decrypt(aplicacion.key); string[] keyUser = aplicacionKey.Split(':'); string usuario = keyUser.FirstOrDefault(); string llaveApp = keyUser.LastOrDefault(); ApplicacionLlaveDTO applicacionLlave = applicacionLlaveService.LlaveApplicacion(llaveApp); if (applicacionLlave != null) { UsuarioDTO usuarioDTO = usuarioService.BuscarUsuario(usuario); if (usuarioDTO != null) { JwtAuthToken jwtAuthToken = new Authentication() .GenerateJwtToken(usuarioDTO.NombreUsuario); UsuarioDTO usuarioModel = usuarioDTO; TokenAccesoDTO tokenAcceso = new TokenAccesoDTO { AccesToken = jwtAuthToken.AccessToken, Usuario = usuarioModel.NombreUsuario, UsuarioId = usuarioModel.UsuarioId, PerfilId = usuarioModel.PerfilId, Validado = true, FechaRegistro = DateTime.Now, Activo = true, FechaCreacion = DateTime.Now, FechaCambio = DateTime.Now, UsuarioRed = string.Empty, EstacionRed = string.Empty }; tokenAccesoService.Insert(tokenAcceso); var jsonData = new { usuario = usuarioModel.NombreUsuario, token = jwtAuthToken, url = applicacionLlave.Url, pagina = usuarioDTO.Pagina }; service.Data = jsonData; return(Json(service)); } } } } catch (Exception ex) { service.Success = false; service.Error = ex.Message; _logger.LogError(ex); } return(Json(service)); }
public void UpdateMasterData(ApplicationKey document) { var filter = Builders <ApplicationKey> .Filter.Eq(s => s.Id, document.Id); collectionApplicationKey.ReplaceOne(filter, document); }